mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-26 11:21:51 +01:00
Create WireMock.Net.MimePart project (#1300)
* Create WireMock.Net.MimePart project * . * REFACTOR * ILRepack * -- * ... * x * x * . * fix * public class MimePartMatcher * shared * min * . * <!--<DelaySign>true</DelaySign>--> * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -24,42 +24,103 @@ public class TypeLoaderTests
|
||||
{
|
||||
}
|
||||
|
||||
public interface IDummyInterfaceWithImplementationUsedForStaticTest
|
||||
{
|
||||
}
|
||||
|
||||
public class DummyClass1UsedForStaticTest : IDummyInterfaceWithImplementationUsedForStaticTest
|
||||
{
|
||||
public DummyClass1UsedForStaticTest(Counter counter)
|
||||
{
|
||||
counter.AddOne();
|
||||
}
|
||||
}
|
||||
|
||||
public class DummyClass2UsedForStaticTest : IDummyInterfaceWithImplementationUsedForStaticTest
|
||||
{
|
||||
public DummyClass2UsedForStaticTest(Counter counter)
|
||||
{
|
||||
counter.AddOne();
|
||||
}
|
||||
}
|
||||
|
||||
public class Counter
|
||||
{
|
||||
public int Value { get; private set; }
|
||||
|
||||
public void AddOne()
|
||||
{
|
||||
Value++;
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Load_ByInterface()
|
||||
public void LoadNewInstance()
|
||||
{
|
||||
// Act
|
||||
AnyOf<string, StringPattern> pattern = "x";
|
||||
var result = TypeLoader.Load<ICSharpCodeMatcher>(MatchBehaviour.AcceptOnMatch, MatchOperator.Or, pattern);
|
||||
var result = TypeLoader.LoadNewInstance<ICSharpCodeMatcher>(MatchBehaviour.AcceptOnMatch, MatchOperator.Or, pattern);
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Load_ByInterfaceAndFullName()
|
||||
public void LoadNewInstanceByFullName()
|
||||
{
|
||||
// Act
|
||||
var result = TypeLoader.LoadByFullName<IDummyInterfaceWithImplementation>(typeof(DummyClass).FullName!);
|
||||
var result = TypeLoader.LoadNewInstanceByFullName<IDummyInterfaceWithImplementation>(typeof(DummyClass).FullName!);
|
||||
|
||||
// Assert
|
||||
result.Should().BeOfType<DummyClass>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Load_ByInterface_ButNoImplementationFoundForInterface_ThrowsException()
|
||||
public void LoadStaticInstance_ShouldOnlyCreateInstanceOnce()
|
||||
{
|
||||
// Arrange
|
||||
var counter = new Counter();
|
||||
|
||||
// Act
|
||||
var result = TypeLoader.LoadStaticInstance<IDummyInterfaceWithImplementationUsedForStaticTest>(counter);
|
||||
TypeLoader.LoadStaticInstance<IDummyInterfaceWithImplementationUsedForStaticTest>(counter);
|
||||
|
||||
// Assert
|
||||
result.Should().BeOfType<DummyClass1UsedForStaticTest>();
|
||||
counter.Value.Should().Be(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LoadStaticInstanceByFullName_ShouldOnlyCreateInstanceOnce()
|
||||
{
|
||||
// Arrange
|
||||
var counter = new Counter();
|
||||
var fullName = typeof(DummyClass2UsedForStaticTest).FullName!;
|
||||
|
||||
// Act
|
||||
var result = TypeLoader.LoadStaticInstanceByFullName<IDummyInterfaceWithImplementationUsedForStaticTest>(fullName, counter);
|
||||
TypeLoader.LoadStaticInstanceByFullName<IDummyInterfaceWithImplementationUsedForStaticTest>(fullName, counter);
|
||||
|
||||
// Assert
|
||||
result.Should().BeOfType<DummyClass2UsedForStaticTest>();
|
||||
counter.Value.Should().Be(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LoadNewInstance_ButNoImplementationFoundForInterface_ThrowsException()
|
||||
{
|
||||
// Act
|
||||
Action a = () => TypeLoader.Load<IDummyInterfaceNoImplementation>();
|
||||
Action a = () => TypeLoader.LoadNewInstance<IDummyInterfaceNoImplementation>();
|
||||
|
||||
// Assert
|
||||
a.Should().Throw<DllNotFoundException>().WithMessage("No dll found which implements Interface 'WireMock.Net.Tests.Util.TypeLoaderTests+IDummyInterfaceNoImplementation'.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Load_ByInterfaceAndFullName_ButNoImplementationFoundForInterface_ThrowsException()
|
||||
public void LoadNewInstanceByFullName_ButNoImplementationFoundForInterface_ThrowsException()
|
||||
{
|
||||
// Act
|
||||
Action a = () => TypeLoader.LoadByFullName<IDummyInterfaceWithImplementation>("xyz");
|
||||
Action a = () => TypeLoader.LoadNewInstanceByFullName<IDummyInterfaceWithImplementation>("xyz");
|
||||
|
||||
// Assert
|
||||
a.Should().Throw<DllNotFoundException>().WithMessage("No dll found which implements Interface 'WireMock.Net.Tests.Util.TypeLoaderTests+IDummyInterfaceWithImplementation' and has FullName 'xyz'.");
|
||||
|
||||
Reference in New Issue
Block a user