mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 18:22:49 +08:00
Started adding BDDfy...
This commit is contained in:
parent
b2c1e627bb
commit
6d46829ce2
@ -9,6 +9,7 @@ using Shouldly;
|
|||||||
namespace Ocelot.AcceptanceTests
|
namespace Ocelot.AcceptanceTests
|
||||||
{
|
{
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using TestStack.BDDfy;
|
||||||
|
|
||||||
public class RouterTests : IDisposable
|
public class RouterTests : IDisposable
|
||||||
{
|
{
|
||||||
@ -30,8 +31,9 @@ namespace Ocelot.AcceptanceTests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void should_return_response_404()
|
public void should_return_response_404()
|
||||||
{
|
{
|
||||||
WhenIRequestTheUrl("/");
|
this.When(x => x.WhenIRequestTheUrl("/"))
|
||||||
ThenTheStatusCodeShouldBe(HttpStatusCode.NotFound);
|
.Then(x => x.ThenTheStatusCodeShouldBe(HttpStatusCode.NotFound))
|
||||||
|
.BDDfy();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WhenIRequestTheUrl(string url)
|
private void WhenIRequestTheUrl(string url)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"version": "1.0.0-*",
|
||||||
|
|
||||||
"testRunner": "xunit",
|
"testRunner": "xunit",
|
||||||
@ -24,7 +24,8 @@
|
|||||||
"dotnet-test-xunit": "2.2.0-preview2-build1029",
|
"dotnet-test-xunit": "2.2.0-preview2-build1029",
|
||||||
"Shouldly": "2.8.0",
|
"Shouldly": "2.8.0",
|
||||||
"Ocelot": "1.0.0-*",
|
"Ocelot": "1.0.0-*",
|
||||||
"Microsoft.AspNetCore.TestHost": "1.0.0"
|
"Microsoft.AspNetCore.TestHost": "1.0.0",
|
||||||
|
"TestStack.BDDfy": "4.3.1"
|
||||||
},
|
},
|
||||||
|
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
|
@ -5,6 +5,8 @@ using Xunit;
|
|||||||
|
|
||||||
namespace Ocelot.UnitTests
|
namespace Ocelot.UnitTests
|
||||||
{
|
{
|
||||||
|
using TestStack.BDDfy;
|
||||||
|
|
||||||
public class HostUrlMapRepositoryTests
|
public class HostUrlMapRepositoryTests
|
||||||
{
|
{
|
||||||
private string _upstreamBaseUrl;
|
private string _upstreamBaseUrl;
|
||||||
@ -21,34 +23,38 @@ namespace Ocelot.UnitTests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void can_add_route()
|
public void can_add_route()
|
||||||
{
|
{
|
||||||
GivenIHaveAnUpstreamBaseUrl("www.someapi.com");
|
this.Given(x => x.GivenIHaveAnUpstreamBaseUrl("www.someapi.com"))
|
||||||
GivenIWantToRouteRequestsFromMyDownstreamBaseUrl("api");
|
.And(x => x.GivenIWantToRouteRequestsFromMyDownstreamBaseUrl("api"))
|
||||||
WhenIAddTheConfiguration();
|
.When(x => x.WhenIAddTheConfiguration())
|
||||||
ThenTheResponseIsSuccesful();
|
.Then(x => x.ThenTheResponseIsSuccesful())
|
||||||
|
.BDDfy();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void can_get_route_by_key()
|
public void can_get_route_by_key()
|
||||||
{
|
{
|
||||||
GivenIHaveSetUpAnApiKeyAndUpstreamUrl("api2", "www.someapi.com");
|
this.Given(x => x.GivenIHaveSetUpAnApiKeyAndUpstreamUrl("api2", "www.someapi.com"))
|
||||||
WhenIRetrieveTheRouteByKey();
|
.When(x => x.WhenIRetrieveTheRouteByKey())
|
||||||
ThenTheRouteIsReturned();
|
.Then(x => x.ThenTheRouteIsReturned())
|
||||||
|
.BDDfy();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void should_return_error_response_when_key_already_used()
|
public void should_return_error_response_when_key_already_used()
|
||||||
{
|
{
|
||||||
GivenIHaveSetUpAnApiKeyAndUpstreamUrl("api2", "www.someapi.com");
|
this.Given(x => x.GivenIHaveSetUpAnApiKeyAndUpstreamUrl("api2", "www.someapi.com"))
|
||||||
WhenITryToUseTheSameKey();
|
.When(x => x.WhenITryToUseTheSameKey())
|
||||||
ThenTheKeyHasAlreadyBeenUsed();
|
.Then(x => x.ThenTheKeyHasAlreadyBeenUsed())
|
||||||
|
.BDDfy();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void should_return_error_response_if_key_doesnt_exist()
|
public void should_return_error_response_if_key_doesnt_exist()
|
||||||
{
|
{
|
||||||
GivenIWantToRouteRequestsFromMyDownstreamBaseUrl("api");
|
this.Given(x => x.GivenIWantToRouteRequestsFromMyDownstreamBaseUrl("api"))
|
||||||
WhenIRetrieveTheRouteByKey();
|
.When(x => x.WhenIRetrieveTheRouteByKey())
|
||||||
ThenTheKeyDoesNotExist();
|
.Then(x => x.ThenTheKeyDoesNotExist())
|
||||||
|
.BDDfy();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WhenITryToUseTheSameKey()
|
private void WhenITryToUseTheSameKey()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"version": "1.0.0-*",
|
||||||
|
|
||||||
"testRunner": "xunit",
|
"testRunner": "xunit",
|
||||||
@ -22,7 +22,8 @@
|
|||||||
"Ocelot.Library": "1.0.0-*",
|
"Ocelot.Library": "1.0.0-*",
|
||||||
"xunit": "2.1.0",
|
"xunit": "2.1.0",
|
||||||
"dotnet-test-xunit": "2.2.0-preview2-build1029",
|
"dotnet-test-xunit": "2.2.0-preview2-build1029",
|
||||||
"Shouldly": "2.8.0"
|
"Shouldly": "2.8.0",
|
||||||
|
"TestStack.BDDfy": "4.3.1"
|
||||||
},
|
},
|
||||||
|
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user