mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-11 03:37:11 +02:00
Rewrite some unit-integration-tests to unit-tests (#206)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using NFluent;
|
||||
using WireMock.Logging;
|
||||
using WireMock.Owin;
|
||||
using WireMock.Server;
|
||||
using WireMock.Settings;
|
||||
@@ -9,6 +11,14 @@ namespace WireMock.Net.Tests
|
||||
{
|
||||
public class FluentMockServerSettingsTests
|
||||
{
|
||||
private Mock<IWireMockLogger> _loggerMock;
|
||||
|
||||
public FluentMockServerSettingsTests()
|
||||
{
|
||||
_loggerMock = new Mock<IWireMockLogger>();
|
||||
_loggerMock.Setup(l => l.Info(It.IsAny<string>(), It.IsAny<object[]>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FluentMockServer_FluentMockServerSettings_StartAdminInterfaceTrue_BasicAuthenticationIsSet()
|
||||
{
|
||||
@@ -21,7 +31,7 @@ namespace WireMock.Net.Tests
|
||||
});
|
||||
|
||||
// Assert
|
||||
var options = server.GetPrivateFieldValue<WireMockMiddlewareOptions>("_options");
|
||||
var options = server.GetPrivateFieldValue<IWireMockMiddlewareOptions>("_options");
|
||||
Check.That(options.AuthorizationMatcher).IsNotNull();
|
||||
}
|
||||
|
||||
@@ -37,7 +47,7 @@ namespace WireMock.Net.Tests
|
||||
});
|
||||
|
||||
// Assert
|
||||
var options = server.GetPrivateFieldValue<WireMockMiddlewareOptions>("_options");
|
||||
var options = server.GetPrivateFieldValue<IWireMockMiddlewareOptions>("_options");
|
||||
Check.That(options.AuthorizationMatcher).IsNull();
|
||||
}
|
||||
|
||||
@@ -93,5 +103,38 @@ namespace WireMock.Net.Tests
|
||||
Check.That(mappings.Count()).IsEqualTo(1);
|
||||
Check.That(mappings[0].Priority).IsEqualTo(0);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FluentMockServer_FluentMockServerSettings_AllowPartialMapping()
|
||||
{
|
||||
// Assign and Act
|
||||
var server = FluentMockServer.Start(new FluentMockServerSettings
|
||||
{
|
||||
Logger = _loggerMock.Object,
|
||||
AllowPartialMapping = true
|
||||
});
|
||||
|
||||
// Assert
|
||||
var options = server.GetPrivateFieldValue<IWireMockMiddlewareOptions>("_options");
|
||||
Check.That(options.AllowPartialMapping).IsTrue();
|
||||
|
||||
// Verify
|
||||
_loggerMock.Verify(l => l.Info(It.IsAny<string>(), It.IsAny<bool>()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FluentMockServer_FluentMockServerSettings_RequestLogExpirationDuration()
|
||||
{
|
||||
// Assign and Act
|
||||
var server = FluentMockServer.Start(new FluentMockServerSettings
|
||||
{
|
||||
Logger = _loggerMock.Object,
|
||||
RequestLogExpirationDuration = 1
|
||||
});
|
||||
|
||||
// Assert
|
||||
var options = server.GetPrivateFieldValue<IWireMockMiddlewareOptions>("_options");
|
||||
Check.That(options.RequestLogExpirationDuration).IsEqualTo(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user