Started adding BDDfy...

This commit is contained in:
Tom Pallister
2016-08-24 17:51:55 +01:00
parent b2c1e627bb
commit 6d46829ce2
4 changed files with 29 additions and 19 deletions

View File

@ -5,6 +5,8 @@ using Xunit;
namespace Ocelot.UnitTests
{
using TestStack.BDDfy;
public class HostUrlMapRepositoryTests
{
private string _upstreamBaseUrl;
@ -21,34 +23,38 @@ namespace Ocelot.UnitTests
[Fact]
public void can_add_route()
{
GivenIHaveAnUpstreamBaseUrl("www.someapi.com");
GivenIWantToRouteRequestsFromMyDownstreamBaseUrl("api");
WhenIAddTheConfiguration();
ThenTheResponseIsSuccesful();
this.Given(x => x.GivenIHaveAnUpstreamBaseUrl("www.someapi.com"))
.And(x => x.GivenIWantToRouteRequestsFromMyDownstreamBaseUrl("api"))
.When(x => x.WhenIAddTheConfiguration())
.Then(x => x.ThenTheResponseIsSuccesful())
.BDDfy();
}
[Fact]
public void can_get_route_by_key()
{
GivenIHaveSetUpAnApiKeyAndUpstreamUrl("api2", "www.someapi.com");
WhenIRetrieveTheRouteByKey();
ThenTheRouteIsReturned();
this.Given(x => x.GivenIHaveSetUpAnApiKeyAndUpstreamUrl("api2", "www.someapi.com"))
.When(x => x.WhenIRetrieveTheRouteByKey())
.Then(x => x.ThenTheRouteIsReturned())
.BDDfy();
}
[Fact]
public void should_return_error_response_when_key_already_used()
{
GivenIHaveSetUpAnApiKeyAndUpstreamUrl("api2", "www.someapi.com");
WhenITryToUseTheSameKey();
ThenTheKeyHasAlreadyBeenUsed();
this.Given(x => x.GivenIHaveSetUpAnApiKeyAndUpstreamUrl("api2", "www.someapi.com"))
.When(x => x.WhenITryToUseTheSameKey())
.Then(x => x.ThenTheKeyHasAlreadyBeenUsed())
.BDDfy();
}
[Fact]
public void should_return_error_response_if_key_doesnt_exist()
{
GivenIWantToRouteRequestsFromMyDownstreamBaseUrl("api");
WhenIRetrieveTheRouteByKey();
ThenTheKeyDoesNotExist();
this.Given(x => x.GivenIWantToRouteRequestsFromMyDownstreamBaseUrl("api"))
.When(x => x.WhenIRetrieveTheRouteByKey())
.Then(x => x.ThenTheKeyDoesNotExist())
.BDDfy();
}
private void WhenITryToUseTheSameKey()

View File

@ -1,4 +1,4 @@
{
{
"version": "1.0.0-*",
"testRunner": "xunit",
@ -22,7 +22,8 @@
"Ocelot.Library": "1.0.0-*",
"xunit": "2.1.0",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"Shouldly": "2.8.0"
"Shouldly": "2.8.0",
"TestStack.BDDfy": "4.3.1"
},
"frameworks": {