mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-25 02:41:53 +01:00
@@ -1,37 +0,0 @@
|
||||
using System;
|
||||
using AnyOfTypes;
|
||||
using FluentAssertions;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.Models;
|
||||
using WireMock.Plugin;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.Plugin;
|
||||
|
||||
public class PluginLoaderTests
|
||||
{
|
||||
public interface IDummy
|
||||
{
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Load_Valid()
|
||||
{
|
||||
// Act
|
||||
AnyOf<string, StringPattern> pattern = "x";
|
||||
var result = PluginLoader.Load<ICSharpCodeMatcher>(MatchBehaviour.AcceptOnMatch, MatchOperator.Or, pattern);
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Load_Invalid_ThrowsException()
|
||||
{
|
||||
// Act
|
||||
Action a = () => PluginLoader.Load<IDummy>();
|
||||
|
||||
// Assert
|
||||
a.Should().Throw<DllNotFoundException>();
|
||||
}
|
||||
}
|
||||
65
test/WireMock.Net.Tests/Util/TypeLoaderTests.cs
Normal file
65
test/WireMock.Net.Tests/Util/TypeLoaderTests.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using AnyOfTypes;
|
||||
using FluentAssertions;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.Models;
|
||||
using WireMock.Util;
|
||||
using Xunit;
|
||||
|
||||
namespace WireMock.Net.Tests.Util;
|
||||
|
||||
public class TypeLoaderTests
|
||||
{
|
||||
public interface IDummyInterfaceNoImplementation
|
||||
{
|
||||
}
|
||||
|
||||
public interface IDummyInterfaceWithImplementation
|
||||
{
|
||||
}
|
||||
|
||||
public class DummyClass : IDummyInterfaceWithImplementation
|
||||
{
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Load_ByInterface()
|
||||
{
|
||||
// Act
|
||||
AnyOf<string, StringPattern> pattern = "x";
|
||||
var result = TypeLoader.Load<ICSharpCodeMatcher>(MatchBehaviour.AcceptOnMatch, MatchOperator.Or, pattern);
|
||||
|
||||
// Assert
|
||||
result.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Load_ByInterfaceAndFullName()
|
||||
{
|
||||
// Act
|
||||
var result = TypeLoader.LoadByFullName<IDummyInterfaceWithImplementation>(typeof(DummyClass).FullName!);
|
||||
|
||||
// Assert
|
||||
result.Should().BeOfType<DummyClass>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Load_ByInterface_ButNoImplementationFoundForInterface_ThrowsException()
|
||||
{
|
||||
// Act
|
||||
Action a = () => TypeLoader.Load<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()
|
||||
{
|
||||
// Act
|
||||
Action a = () => TypeLoader.LoadByFullName<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