mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 18:22:49 +08:00
unit tests passing
This commit is contained in:
parent
b8922cef5f
commit
e969e9ff0b
@ -257,7 +257,7 @@ namespace Ocelot.Configuration.Builder
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DownstreamReRouteBuilder WithHttpVersion(Version downstreamHttpVersion)
|
public DownstreamReRouteBuilder WithDownstreamHttpVersion(Version downstreamHttpVersion)
|
||||||
{
|
{
|
||||||
_downstreamHttpVersion = downstreamHttpVersion;
|
_downstreamHttpVersion = downstreamHttpVersion;
|
||||||
return this;
|
return this;
|
||||||
|
@ -143,7 +143,7 @@ namespace Ocelot.Configuration.Creator
|
|||||||
.WithAddHeadersToUpstream(hAndRs.AddHeadersToUpstream)
|
.WithAddHeadersToUpstream(hAndRs.AddHeadersToUpstream)
|
||||||
.WithDangerousAcceptAnyServerCertificateValidator(fileReRoute.DangerousAcceptAnyServerCertificateValidator)
|
.WithDangerousAcceptAnyServerCertificateValidator(fileReRoute.DangerousAcceptAnyServerCertificateValidator)
|
||||||
.WithSecurityOptions(securityOptions)
|
.WithSecurityOptions(securityOptions)
|
||||||
.WithHttpVersion(downstreamHttpVersion)
|
.WithDownstreamHttpVersion(downstreamHttpVersion)
|
||||||
.WithDownStreamHttpMethod(fileReRoute.DownstreamHttpMethod)
|
.WithDownStreamHttpMethod(fileReRoute.DownstreamHttpMethod)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
namespace Ocelot.UnitTests.Configuration
|
namespace Ocelot.UnitTests.Configuration
|
||||||
{
|
{
|
||||||
|
using System;
|
||||||
using Ocelot.Configuration.Creator;
|
using Ocelot.Configuration.Creator;
|
||||||
using Shouldly;
|
using Shouldly;
|
||||||
|
using TestStack.BDDfy;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
public class VersionCreatorTests
|
public class VersionCreatorTests
|
||||||
{
|
{
|
||||||
private readonly VersionCreator _creator;
|
private readonly VersionCreator _creator;
|
||||||
|
private string _input;
|
||||||
|
private Version _result;
|
||||||
|
|
||||||
public VersionCreatorTests()
|
public VersionCreatorTests()
|
||||||
{
|
{
|
||||||
@ -16,19 +20,35 @@
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void should_create_version_based_on_input()
|
public void should_create_version_based_on_input()
|
||||||
{
|
{
|
||||||
var input = "2.0";
|
this.Given(_ => GivenTheInput("2.0"))
|
||||||
var result = _creator.Create(input);
|
.When(_ => WhenICreate())
|
||||||
result.Major.ShouldBe(2);
|
.Then(_ => ThenTheResultIs(2, 0))
|
||||||
result.Minor.ShouldBe(0);
|
.BDDfy();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void should_default_to_version_one_point_one()
|
public void should_default_to_version_one_point_one()
|
||||||
{
|
{
|
||||||
var input = "";
|
this.Given(_ => GivenTheInput(""))
|
||||||
var result = _creator.Create(input);
|
.When(_ => WhenICreate())
|
||||||
result.Major.ShouldBe(1);
|
.Then(_ => ThenTheResultIs(1, 1))
|
||||||
result.Minor.ShouldBe(1);
|
.BDDfy();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GivenTheInput(string input)
|
||||||
|
{
|
||||||
|
_input = input;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void WhenICreate()
|
||||||
|
{
|
||||||
|
_result = _creator.Create(_input);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ThenTheResultIs(int major, int minor)
|
||||||
|
{
|
||||||
|
_result.Major.ShouldBe(major);
|
||||||
|
_result.Minor.ShouldBe(minor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
.And(_ => GivenTheInputRequestHasHost(host))
|
.And(_ => GivenTheInputRequestHasHost(host))
|
||||||
.And(_ => GivenTheInputRequestHasPath(path))
|
.And(_ => GivenTheInputRequestHasPath(path))
|
||||||
.And(_ => GivenTheInputRequestHasQueryString(queryString))
|
.And(_ => GivenTheInputRequestHasQueryString(queryString))
|
||||||
|
.And(_ => GivenTheDownstreamReRoute())
|
||||||
.When(_ => WhenMapped())
|
.When(_ => WhenMapped())
|
||||||
.Then(_ => ThenNoErrorIsReturned())
|
.Then(_ => ThenNoErrorIsReturned())
|
||||||
.And(_ => ThenTheMappedRequestHasUri(expectedUri))
|
.And(_ => ThenTheMappedRequestHasUri(expectedUri))
|
||||||
@ -80,6 +81,7 @@
|
|||||||
{
|
{
|
||||||
this.Given(_ => GivenTheInputRequestHasMethod(method))
|
this.Given(_ => GivenTheInputRequestHasMethod(method))
|
||||||
.And(_ => GivenTheInputRequestHasAValidUri())
|
.And(_ => GivenTheInputRequestHasAValidUri())
|
||||||
|
.And(_ => GivenTheDownstreamReRoute())
|
||||||
.When(_ => WhenMapped())
|
.When(_ => WhenMapped())
|
||||||
.Then(_ => ThenNoErrorIsReturned())
|
.Then(_ => ThenNoErrorIsReturned())
|
||||||
.And(_ => ThenTheMappedRequestHasMethod(method))
|
.And(_ => ThenTheMappedRequestHasMethod(method))
|
||||||
@ -107,6 +109,7 @@
|
|||||||
this.Given(_ => GivenTheInputRequestHasHeaders())
|
this.Given(_ => GivenTheInputRequestHasHeaders())
|
||||||
.And(_ => GivenTheInputRequestHasMethod("GET"))
|
.And(_ => GivenTheInputRequestHasMethod("GET"))
|
||||||
.And(_ => GivenTheInputRequestHasAValidUri())
|
.And(_ => GivenTheInputRequestHasAValidUri())
|
||||||
|
.And(_ => GivenTheDownstreamReRoute())
|
||||||
.When(_ => WhenMapped())
|
.When(_ => WhenMapped())
|
||||||
.Then(_ => ThenNoErrorIsReturned())
|
.Then(_ => ThenNoErrorIsReturned())
|
||||||
.And(_ => ThenTheMappedRequestHasEachHeader())
|
.And(_ => ThenTheMappedRequestHasEachHeader())
|
||||||
@ -119,6 +122,7 @@
|
|||||||
this.Given(_ => GivenTheInputRequestHasNoHeaders())
|
this.Given(_ => GivenTheInputRequestHasNoHeaders())
|
||||||
.And(_ => GivenTheInputRequestHasMethod("GET"))
|
.And(_ => GivenTheInputRequestHasMethod("GET"))
|
||||||
.And(_ => GivenTheInputRequestHasAValidUri())
|
.And(_ => GivenTheInputRequestHasAValidUri())
|
||||||
|
.And(_ => GivenTheDownstreamReRoute())
|
||||||
.When(_ => WhenMapped())
|
.When(_ => WhenMapped())
|
||||||
.Then(_ => ThenNoErrorIsReturned())
|
.Then(_ => ThenNoErrorIsReturned())
|
||||||
.And(_ => ThenTheMappedRequestHasNoHeaders())
|
.And(_ => ThenTheMappedRequestHasNoHeaders())
|
||||||
@ -131,6 +135,7 @@
|
|||||||
this.Given(_ => GivenTheInputRequestHasContent("This is my content"))
|
this.Given(_ => GivenTheInputRequestHasContent("This is my content"))
|
||||||
.And(_ => GivenTheInputRequestHasMethod("GET"))
|
.And(_ => GivenTheInputRequestHasMethod("GET"))
|
||||||
.And(_ => GivenTheInputRequestHasAValidUri())
|
.And(_ => GivenTheInputRequestHasAValidUri())
|
||||||
|
.And(_ => GivenTheDownstreamReRoute())
|
||||||
.When(_ => WhenMapped())
|
.When(_ => WhenMapped())
|
||||||
.Then(_ => ThenNoErrorIsReturned())
|
.Then(_ => ThenNoErrorIsReturned())
|
||||||
.And(_ => ThenTheMappedRequestHasContent("This is my content"))
|
.And(_ => ThenTheMappedRequestHasContent("This is my content"))
|
||||||
@ -143,6 +148,7 @@
|
|||||||
this.Given(_ => GivenTheInputRequestHasNullContent())
|
this.Given(_ => GivenTheInputRequestHasNullContent())
|
||||||
.And(_ => GivenTheInputRequestHasMethod("GET"))
|
.And(_ => GivenTheInputRequestHasMethod("GET"))
|
||||||
.And(_ => GivenTheInputRequestHasAValidUri())
|
.And(_ => GivenTheInputRequestHasAValidUri())
|
||||||
|
.And(_ => GivenTheDownstreamReRoute())
|
||||||
.When(_ => WhenMapped())
|
.When(_ => WhenMapped())
|
||||||
.Then(_ => ThenNoErrorIsReturned())
|
.Then(_ => ThenNoErrorIsReturned())
|
||||||
.And(_ => ThenTheMappedRequestHasNoContent())
|
.And(_ => ThenTheMappedRequestHasNoContent())
|
||||||
@ -155,6 +161,7 @@
|
|||||||
this.Given(_ => GivenTheInputRequestHasNoContentType())
|
this.Given(_ => GivenTheInputRequestHasNoContentType())
|
||||||
.And(_ => GivenTheInputRequestHasMethod("GET"))
|
.And(_ => GivenTheInputRequestHasMethod("GET"))
|
||||||
.And(_ => GivenTheInputRequestHasAValidUri())
|
.And(_ => GivenTheInputRequestHasAValidUri())
|
||||||
|
.And(_ => GivenTheDownstreamReRoute())
|
||||||
.When(_ => WhenMapped())
|
.When(_ => WhenMapped())
|
||||||
.Then(_ => ThenNoErrorIsReturned())
|
.Then(_ => ThenNoErrorIsReturned())
|
||||||
.And(_ => ThenTheMappedRequestHasNoContent())
|
.And(_ => ThenTheMappedRequestHasNoContent())
|
||||||
@ -167,6 +174,7 @@
|
|||||||
this.Given(_ => GivenTheInputRequestHasNoContentLength())
|
this.Given(_ => GivenTheInputRequestHasNoContentLength())
|
||||||
.And(_ => GivenTheInputRequestHasMethod("GET"))
|
.And(_ => GivenTheInputRequestHasMethod("GET"))
|
||||||
.And(_ => GivenTheInputRequestHasAValidUri())
|
.And(_ => GivenTheInputRequestHasAValidUri())
|
||||||
|
.And(_ => GivenTheDownstreamReRoute())
|
||||||
.When(_ => WhenMapped())
|
.When(_ => WhenMapped())
|
||||||
.Then(_ => ThenNoErrorIsReturned())
|
.Then(_ => ThenNoErrorIsReturned())
|
||||||
.And(_ => ThenTheMappedRequestHasNoContent())
|
.And(_ => ThenTheMappedRequestHasNoContent())
|
||||||
@ -192,6 +200,7 @@
|
|||||||
.And(_ => GivenTheContentMD5Is(md5bytes))
|
.And(_ => GivenTheContentMD5Is(md5bytes))
|
||||||
.And(_ => GivenTheInputRequestHasMethod("GET"))
|
.And(_ => GivenTheInputRequestHasMethod("GET"))
|
||||||
.And(_ => GivenTheInputRequestHasAValidUri())
|
.And(_ => GivenTheInputRequestHasAValidUri())
|
||||||
|
.And(_ => GivenTheDownstreamReRoute())
|
||||||
.When(_ => WhenMapped())
|
.When(_ => WhenMapped())
|
||||||
.Then(_ => ThenNoErrorIsReturned())
|
.Then(_ => ThenNoErrorIsReturned())
|
||||||
.And(_ => ThenTheMappedRequestHasContentTypeHeader("application/json"))
|
.And(_ => ThenTheMappedRequestHasContentTypeHeader("application/json"))
|
||||||
@ -213,6 +222,7 @@
|
|||||||
.And(_ => GivenTheContentTypeIs("application/json"))
|
.And(_ => GivenTheContentTypeIs("application/json"))
|
||||||
.And(_ => GivenTheInputRequestHasMethod("POST"))
|
.And(_ => GivenTheInputRequestHasMethod("POST"))
|
||||||
.And(_ => GivenTheInputRequestHasAValidUri())
|
.And(_ => GivenTheInputRequestHasAValidUri())
|
||||||
|
.And(_ => GivenTheDownstreamReRoute())
|
||||||
.When(_ => WhenMapped())
|
.When(_ => WhenMapped())
|
||||||
.Then(_ => ThenNoErrorIsReturned())
|
.Then(_ => ThenNoErrorIsReturned())
|
||||||
.And(_ => ThenTheMappedRequestHasContentTypeHeader("application/json"))
|
.And(_ => ThenTheMappedRequestHasContentTypeHeader("application/json"))
|
||||||
@ -223,7 +233,15 @@
|
|||||||
|
|
||||||
private void GivenTheDownstreamReRouteMethodIs(string input)
|
private void GivenTheDownstreamReRouteMethodIs(string input)
|
||||||
{
|
{
|
||||||
_downstreamReRoute = new DownstreamReRouteBuilder().WithDownStreamHttpMethod(input).Build();
|
_downstreamReRoute = new DownstreamReRouteBuilder()
|
||||||
|
.WithDownStreamHttpMethod(input)
|
||||||
|
.WithDownstreamHttpVersion(new Version("1.1")).Build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GivenTheDownstreamReRoute()
|
||||||
|
{
|
||||||
|
_downstreamReRoute = new DownstreamReRouteBuilder()
|
||||||
|
.WithDownstreamHttpVersion(new Version("1.1")).Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GivenTheInputRequestHasNoContentLength()
|
private void GivenTheInputRequestHasNoContentLength()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user