diff --git a/test/Ocelot.UnitTests/Configuration/RoutesCreatorTests.cs b/test/Ocelot.UnitTests/Configuration/RoutesCreatorTests.cs index 9a3e9f1f7..4fdd9cd95 100644 --- a/test/Ocelot.UnitTests/Configuration/RoutesCreatorTests.cs +++ b/test/Ocelot.UnitTests/Configuration/RoutesCreatorTests.cs @@ -1,8 +1,8 @@ -using Ocelot.Configuration; -using Ocelot.Configuration.Builder; -using Ocelot.Configuration.Creator; -using Ocelot.Configuration.File; -using Ocelot.Values; +using Ocelot.Configuration; +using Ocelot.Configuration.Builder; +using Ocelot.Configuration.Creator; +using Ocelot.Configuration.File; +using Ocelot.Values; namespace Ocelot.UnitTests.Configuration { @@ -25,8 +25,8 @@ public class RoutesCreatorTests : UnitTest private readonly Mock _rrkCreator; private readonly Mock _soCreator; private readonly Mock _versionCreator; - private readonly Mock _versionPolicyCreator; - private readonly Mock _metadataCreator; + private readonly Mock _versionPolicyCreator; + private readonly Mock _metadataCreator; private FileConfiguration _fileConfig; private RouteOptions _rro; private string _requestId; @@ -42,8 +42,8 @@ public class RoutesCreatorTests : UnitTest private List _dhp; private LoadBalancerOptions _lbo; private List _result; - private Version _expectedVersion; - private HttpVersionPolicy _expectedVersionPolicy; + private Version _expectedVersion; + private HttpVersionPolicy _expectedVersionPolicy; private Dictionary _uht; private Dictionary _expectedMetadata; @@ -64,9 +64,9 @@ public RoutesCreatorTests() _rrkCreator = new Mock(); _soCreator = new Mock(); _versionCreator = new Mock(); - _versionPolicyCreator = new Mock(); + _versionPolicyCreator = new Mock(); _uhtpCreator = new Mock(); - _metadataCreator = new Mock(); + _metadataCreator = new Mock(); _creator = new RoutesCreator( _cthCreator.Object, @@ -83,7 +83,7 @@ public RoutesCreatorTests() _lboCreator.Object, _rrkCreator.Object, _soCreator.Object, - _versionCreator.Object, + _versionCreator.Object, _versionPolicyCreator.Object, _uhtpCreator.Object, _metadataCreator.Object); @@ -123,7 +123,7 @@ public void Should_return_routes() { { "e","f" }, }, - UpstreamHttpMethod = new List { "GET", "POST" }, + UpstreamHttpMethod = new List { "GET", "POST" }, Metadata = new Dictionary { ["foo"] = "bar", @@ -149,7 +149,7 @@ public void Should_return_routes() Metadata = new Dictionary { ["foo"] = "baz", - }, + }, }, }, }; @@ -163,29 +163,29 @@ public void Should_return_routes() } [Fact] - public void Should_route_timeout() + public void CreateTimeout_RouteTimeoutIsLessThanGlobalOne_CreatedFromRouteValue() { // Arrange var fileRoute = new FileRoute { Timeout = 10 }; var globalConfiguration = new FileGlobalConfiguration { Timeout = 20 }; - + // Act var timeout = _creator.CreateTimeout(fileRoute, globalConfiguration); - + // Assert Assert.Equal(fileRoute.Timeout, timeout); } [Fact] - public void Should_global_timeout_when_not_route_timeout() + public void CreateTimeout_NoRouteTimeoutAndHasGlobalTimeout_CreatedFromGlobalValue() { // Arrange var fileRoute = new FileRoute(); var globalConfiguration = new FileGlobalConfiguration { Timeout = 20 }; - + // Act var timeout = _creator.CreateTimeout(fileRoute, globalConfiguration); - + // Assert Assert.Equal(globalConfiguration.Timeout, timeout); } @@ -199,7 +199,7 @@ private void ThenTheDependenciesAreCalledCorrectly() private void GivenTheDependenciesAreSetUpCorrectly() { _expectedVersion = new Version("1.1"); - _expectedVersionPolicy = HttpVersionPolicy.RequestVersionOrLower; + _expectedVersionPolicy = HttpVersionPolicy.RequestVersionOrLower; _rro = new RouteOptions(false, false, false, false, false); _requestId = "testy"; _rrk = "besty"; @@ -215,10 +215,10 @@ private void GivenTheDependenciesAreSetUpCorrectly() _dhp = new List(); _lbo = new LoadBalancerOptionsBuilder().Build(); _uht = new Dictionary(); - _expectedMetadata = new Dictionary() - { - ["foo"] = "bar", - }; + _expectedMetadata = new Dictionary() + { + ["foo"] = "bar", + }; _rroCreator.Setup(x => x.Create(It.IsAny())).Returns(_rro); _ridkCreator.Setup(x => x.Create(It.IsAny(), It.IsAny())).Returns(_requestId); @@ -234,12 +234,12 @@ private void GivenTheDependenciesAreSetUpCorrectly() _daCreator.Setup(x => x.Create(It.IsAny())).Returns(_dhp); _lboCreator.Setup(x => x.Create(It.IsAny())).Returns(_lbo); _versionCreator.Setup(x => x.Create(It.IsAny())).Returns(_expectedVersion); - _versionPolicyCreator.Setup(x => x.Create(It.IsAny())).Returns(_expectedVersionPolicy); + _versionPolicyCreator.Setup(x => x.Create(It.IsAny())).Returns(_expectedVersionPolicy); _uhtpCreator.Setup(x => x.Create(It.IsAny())).Returns(_uht); _metadataCreator.Setup(x => x.Create(It.IsAny>(), It.IsAny())).Returns(new MetadataOptions(new FileMetadataOptions { Metadata = _expectedMetadata, - })); + })); } private void ThenTheRoutesAreCreated() @@ -268,7 +268,7 @@ private void WhenICreate() private void ThenTheRouteIsSet(FileRoute expected, int routeIndex) { _result[routeIndex].DownstreamRoute[0].DownstreamHttpVersion.ShouldBe(_expectedVersion); - _result[routeIndex].DownstreamRoute[0].DownstreamHttpVersionPolicy.ShouldBe(_expectedVersionPolicy); + _result[routeIndex].DownstreamRoute[0].DownstreamHttpVersionPolicy.ShouldBe(_expectedVersionPolicy); _result[routeIndex].DownstreamRoute[0].IsAuthenticated.ShouldBe(_rro.IsAuthenticated); _result[routeIndex].DownstreamRoute[0].IsAuthorized.ShouldBe(_rro.IsAuthorized); _result[routeIndex].DownstreamRoute[0].IsCached.ShouldBe(_rro.IsCached); @@ -299,7 +299,7 @@ private void ThenTheRouteIsSet(FileRoute expected, int routeIndex) _result[routeIndex].DownstreamRoute[0].RouteClaimsRequirement.ShouldBe(expected.RouteClaimsRequirement); _result[routeIndex].DownstreamRoute[0].DownstreamPathTemplate.Value.ShouldBe(expected.DownstreamPathTemplate); _result[routeIndex].DownstreamRoute[0].Key.ShouldBe(expected.Key); - _result[routeIndex].DownstreamRoute[0].MetadataOptions.Metadata.ShouldBe(_expectedMetadata); + _result[routeIndex].DownstreamRoute[0].MetadataOptions.Metadata.ShouldBe(_expectedMetadata); _result[routeIndex].UpstreamHttpMethod .Select(x => x.Method) .ToList() @@ -331,7 +331,7 @@ private void ThenTheDepsAreCalledFor(FileRoute fileRoute, FileGlobalConfiguratio _hfarCreator.Verify(x => x.Create(fileRoute), Times.Once); _daCreator.Verify(x => x.Create(fileRoute), Times.Once); _lboCreator.Verify(x => x.Create(fileRoute.LoadBalancerOptions), Times.Once); - _soCreator.Verify(x => x.Create(fileRoute.SecurityOptions), Times.Once); + _soCreator.Verify(x => x.Create(fileRoute.SecurityOptions), Times.Once); _metadataCreator.Verify(x => x.Create(fileRoute.Metadata, globalConfig), Times.Once); } }