Ocelot/test/Ocelot.UnitTests/Configuration/QoSOptionsCreatorTests.cs
Tom Pallister 1e2e953b2c
Feature/automatic routes with sd (#351)
* #340 started looking at supporting automatic routing when using service discovery

* #340 getting old routing tests to pass

* #340 renamed stuff to provider rather than finder, as its not longer finding anything

* #340 working towards supporting dynamic routing

* #340 loads of refactoring to make configuration work with dynamic routing

* #340 refactor consul config code so the registry class owns it

* #340 default to consul to maintain backwards compat

* #340 added docs, finished this branches todos
2018-05-14 21:26:10 +01:00

64 lines
1.9 KiB
C#

using Ocelot.Configuration;
using Ocelot.Configuration.Builder;
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
namespace Ocelot.UnitTests.Configuration
{
public class QoSOptionsCreatorTests
{
private QoSOptionsCreator _creator;
private FileReRoute _fileReRoute;
private QoSOptions _result;
public QoSOptionsCreatorTests()
{
_creator = new QoSOptionsCreator();
}
[Fact]
public void should_create_qos_options()
{
var reRoute = new FileReRoute
{
QoSOptions = new FileQoSOptions
{
ExceptionsAllowedBeforeBreaking = 1,
DurationOfBreak = 1,
TimeoutValue = 1
}
};
var expected = new QoSOptionsBuilder()
.WithDurationOfBreak(1)
.WithExceptionsAllowedBeforeBreaking(1)
.WithTimeoutValue(1)
.Build();
this.Given(x => x.GivenTheFollowingReRoute(reRoute))
.When(x => x.WhenICreate())
.Then(x => x.ThenTheFollowingIsReturned(expected))
.BDDfy();
}
private void GivenTheFollowingReRoute(FileReRoute fileReRoute)
{
_fileReRoute = fileReRoute;
}
private void WhenICreate()
{
_result = _creator.Create(_fileReRoute.QoSOptions);
}
private void ThenTheFollowingIsReturned(QoSOptions expected)
{
_result.DurationOfBreak.ShouldBe(expected.DurationOfBreak);
_result.ExceptionsAllowedBeforeBreaking.ShouldBe(expected.ExceptionsAllowedBeforeBreaking);
_result.TimeoutValue.ShouldBe(expected.TimeoutValue);
}
}
}