Feature/refactoring internal config creation stack (#600)

* tidy up some code so I can understand it

* broke al the things that make config out into their own classes etc..sigh

* fix the things i broked

* #597 test for issue, works on this branch :E

* #597 removed comments

* added tests for new load balancer creator..basic

* added tests for lb creator and aggregates creator

* added tests for config creator

* boiler plate for tests

* added dynamics tests

* wip

* finished refactoring for now
This commit is contained in:
Tom Pallister
2018-09-11 21:41:58 +01:00
committed by GitHub
parent b491bd50a8
commit 44f8e312a8
34 changed files with 2086 additions and 2012 deletions

View File

@ -0,0 +1,54 @@
namespace Ocelot.UnitTests.Configuration
{
using Ocelot.Configuration;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
public class LoadBalancerOptionsCreatorTests
{
private readonly ILoadBalancerOptionsCreator _creator;
private FileLoadBalancerOptions _fileLoadBalancerOptions;
private LoadBalancerOptions _result;
public LoadBalancerOptionsCreatorTests()
{
_creator = new LoadBalancerOptionsCreator();
}
[Fact]
public void should_create()
{
var fileLoadBalancerOptions = new FileLoadBalancerOptions
{
Type = "test",
Key = "west",
Expiry = 1
};
this.Given(_ => GivenThe(fileLoadBalancerOptions))
.When(_ => WhenICreate())
.Then(_ => ThenTheOptionsAreCreated(fileLoadBalancerOptions))
.BDDfy();
}
private void ThenTheOptionsAreCreated(FileLoadBalancerOptions expected)
{
_result.Type.ShouldBe(expected.Type);
_result.Key.ShouldBe(expected.Key);
_result.ExpiryInMs.ShouldBe(expected.Expiry);
}
private void WhenICreate()
{
_result = _creator.Create(_fileLoadBalancerOptions);
}
private void GivenThe(FileLoadBalancerOptions fileLoadBalancerOptions)
{
_fileLoadBalancerOptions = fileLoadBalancerOptions;
}
}
}