Rename all ReRoute to Route to move closer to YARP +semver: breaking

This commit is contained in:
Tom Pallister
2020-05-23 20:50:05 +01:00
committed by GitHub
parent fe3e8bd23a
commit 3439be8927
269 changed files with 23591 additions and 23605 deletions

View File

@ -0,0 +1,84 @@
namespace Ocelot.UnitTests.Configuration
{
using Ocelot.Configuration.Creator;
using Ocelot.Configuration.File;
using Ocelot.LoadBalancer.LoadBalancers;
using Shouldly;
using System.Collections.Generic;
using System.Linq;
using TestStack.BDDfy;
using Xunit;
public class RouteKeyCreatorTests
{
private RouteKeyCreator _creator;
private FileRoute _route;
private string _result;
public RouteKeyCreatorTests()
{
_creator = new RouteKeyCreator();
}
[Fact]
public void should_return_sticky_session_key()
{
var route = new FileRoute
{
LoadBalancerOptions = new FileLoadBalancerOptions
{
Key = "testy",
Type = nameof(CookieStickySessions)
}
};
this.Given(_ => GivenThe(route))
.When(_ => WhenICreate())
.Then(_ => ThenTheResultIs($"{nameof(CookieStickySessions)}:{route.LoadBalancerOptions.Key}"))
.BDDfy();
}
[Fact]
public void should_return_re_route_key()
{
var route = new FileRoute
{
UpstreamPathTemplate = "/api/product",
UpstreamHttpMethod = new List<string> { "GET", "POST", "PUT" },
DownstreamHostAndPorts = new List<FileHostAndPort>
{
new FileHostAndPort
{
Host = "localhost",
Port = 123
},
new FileHostAndPort
{
Host = "localhost",
Port = 123
}
}
};
this.Given(_ => GivenThe(route))
.When(_ => WhenICreate())
.Then(_ => ThenTheResultIs($"{route.UpstreamPathTemplate}|{string.Join(",", route.UpstreamHttpMethod)}|{string.Join(",", route.DownstreamHostAndPorts.Select(x => $"{x.Host}:{x.Port}"))}"))
.BDDfy();
}
private void GivenThe(FileRoute route)
{
_route = route;
}
private void WhenICreate()
{
_result = _creator.Create(_route);
}
private void ThenTheResultIs(string expected)
{
_result.ShouldBe(expected);
}
}
}