another test to make sure service provider config is craeted

This commit is contained in:
Tom Gardham-Pallister 2017-11-09 08:27:38 +00:00
parent bc1ba53f21
commit 0bc39fca53

View File

@ -73,6 +73,30 @@ namespace Ocelot.UnitTests.Configuration
_rateLimitOptions.Object, _regionCreator.Object, _httpHandlerOptionsCreator.Object); _rateLimitOptions.Object, _regionCreator.Object, _httpHandlerOptionsCreator.Object);
} }
[Fact]
public void should_call_service_provider_config_creator()
{
var serviceProviderConfig = new ServiceProviderConfigurationBuilder().Build();
this.Given(x => x.GivenTheConfigIs(new FileConfiguration
{
GlobalConfiguration = new FileGlobalConfiguration
{
ServiceDiscoveryProvider = new FileServiceDiscoveryProvider
{
Host = "localhost",
Port = 8500,
Provider = "consul"
}
}
}))
.And(x => x.GivenTheFollowingIsReturned(serviceProviderConfig))
.And(x => x.GivenTheConfigIsValid())
.When(x => x.WhenICreateTheConfig())
.Then(x => x.ThenTheServiceProviderCreatorIsCalledCorrectly())
.BDDfy();
}
[Fact] [Fact]
public void should_call_region_creator() public void should_call_region_creator()
{ {
@ -652,5 +676,17 @@ namespace Ocelot.UnitTests.Configuration
_config.Data.ReRoutes[0].QosOptionsOptions.ExceptionsAllowedBeforeBreaking.ShouldBe(qosOptions.ExceptionsAllowedBeforeBreaking); _config.Data.ReRoutes[0].QosOptionsOptions.ExceptionsAllowedBeforeBreaking.ShouldBe(qosOptions.ExceptionsAllowedBeforeBreaking);
_config.Data.ReRoutes[0].QosOptionsOptions.TimeoutValue.ShouldBe(qosOptions.TimeoutValue); _config.Data.ReRoutes[0].QosOptionsOptions.TimeoutValue.ShouldBe(qosOptions.TimeoutValue);
} }
private void ThenTheServiceProviderCreatorIsCalledCorrectly()
{
_serviceProviderConfigCreator
.Verify(x => x.Create(_fileConfiguration.GlobalConfiguration), Times.Once);
}
private void GivenTheFollowingIsReturned(ServiceProviderConfiguration serviceProviderConfiguration)
{
_serviceProviderConfigCreator
.Setup(x => x.Create(It.IsAny<FileGlobalConfiguration>())).Returns(serviceProviderConfiguration);
}
} }
} }