mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-18 21:08:16 +08:00
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:
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user