after much hacking unit tests passing

This commit is contained in:
Tom Gardham-Pallister
2017-02-21 07:34:47 +00:00
parent d548a86327
commit 2dfdf0bb86
44 changed files with 313 additions and 194 deletions

View File

@ -16,14 +16,12 @@ namespace Ocelot.UnitTests.Configuration
{
private readonly IOcelotConfigurationProvider _ocelotConfigurationProvider;
private readonly Mock<IOcelotConfigurationRepository> _configurationRepository;
private readonly Mock<IOcelotConfigurationCreator> _creator;
private Response<IOcelotConfiguration> _result;
public FileConfigurationProviderTests()
{
_creator = new Mock<IOcelotConfigurationCreator>();
_configurationRepository = new Mock<IOcelotConfigurationRepository>();
_ocelotConfigurationProvider = new OcelotConfigurationProvider(_configurationRepository.Object, _creator.Object);
_ocelotConfigurationProvider = new OcelotConfigurationProvider(_configurationRepository.Object);
}
[Fact]
@ -35,16 +33,6 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
[Fact]
public void should_create_config_if_it_doesnt_exist()
{
this.Given(x => x.GivenTheRepoReturns(new OkResponse<IOcelotConfiguration>(null)))
.And(x => x.GivenTheCreatorReturns(new OkResponse<IOcelotConfiguration>(new OcelotConfiguration(new List<ReRoute>(), string.Empty))))
.When(x => x.WhenIGetTheConfig())
.Then(x => x.TheFollowingIsReturned(new OkResponse<IOcelotConfiguration>(new OcelotConfiguration(new List<ReRoute>(), string.Empty))))
.BDDfy();
}
[Fact]
public void should_return_error()
{
@ -61,29 +49,6 @@ namespace Ocelot.UnitTests.Configuration
.BDDfy();
}
[Fact]
public void should_return_error_if_creator_errors()
{
this.Given(x => x.GivenTheRepoReturns(new OkResponse<IOcelotConfiguration>(null)))
.And(x => x.GivenTheCreatorReturns(new ErrorResponse<IOcelotConfiguration>(new List<Error>
{
new AnyError()
})))
.When(x => x.WhenIGetTheConfig())
.Then(x => x.TheFollowingIsReturned(new ErrorResponse<IOcelotConfiguration>(new List<Error>
{
new AnyError()
})))
.BDDfy();
}
private void GivenTheCreatorReturns(Response<IOcelotConfiguration> config)
{
_creator
.Setup(x => x.Create())
.ReturnsAsync(config);
}
private void GivenTheRepoReturns(Response<IOcelotConfiguration> config)
{
_configurationRepository
@ -93,7 +58,7 @@ namespace Ocelot.UnitTests.Configuration
private void WhenIGetTheConfig()
{
_result = _ocelotConfigurationProvider.Get().Result;
_result = _ocelotConfigurationProvider.Get();
}
private void TheFollowingIsReturned(Response<IOcelotConfiguration> expected)