Acceptance test for complex url combo...cant believe it acually worked

This commit is contained in:
TomPallister 2016-10-12 20:42:43 +01:00
parent 581c9d01b9
commit 5492b70c87

View File

@ -13,7 +13,6 @@ using TestStack.BDDfy;
using Xunit; using Xunit;
using YamlDotNet.Serialization; using YamlDotNet.Serialization;
[assembly: CollectionBehavior(DisableTestParallelization = true)]
namespace Ocelot.AcceptanceTests namespace Ocelot.AcceptanceTests
{ {
public class OcelotTests : IDisposable public class OcelotTests : IDisposable
@ -31,7 +30,7 @@ namespace Ocelot.AcceptanceTests
} }
[Fact] [Fact]
public void should_return_response_404() public void should_return_response_404_when_no_configuration_at_all()
{ {
this.Given(x => x.GivenThereIsAConfiguration(new YamlConfiguration())) this.Given(x => x.GivenThereIsAConfiguration(new YamlConfiguration()))
.And(x => x.GivenTheApiGatewayIsRunning()) .And(x => x.GivenTheApiGatewayIsRunning())
@ -41,7 +40,7 @@ namespace Ocelot.AcceptanceTests
} }
[Fact] [Fact]
public void should_return_response_200() public void should_return_response_200_with_simple_url()
{ {
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", 200, "Hello from Laura")) this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", 200, "Hello from Laura"))
.And(x => x.GivenThereIsAConfiguration(new YamlConfiguration .And(x => x.GivenThereIsAConfiguration(new YamlConfiguration
@ -64,7 +63,30 @@ namespace Ocelot.AcceptanceTests
} }
[Fact] [Fact]
public void should_return_response_201() public void should_return_response_200_with_complex_url()
{
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879/api/products/1", 200, "Some Product"))
.And(x => x.GivenThereIsAConfiguration(new YamlConfiguration
{
ReRoutes = new List<YamlReRoute>
{
new YamlReRoute
{
DownstreamTemplate = "http://localhost:51879/api/products/{productId}",
UpstreamTemplate = "/products/{productId}",
UpstreamHttpMethod = "Get"
}
}
}))
.And(x => x.GivenTheApiGatewayIsRunning())
.When(x => x.WhenIGetUrlOnTheApiGateway("/products/1"))
.Then(x => x.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
.And(x => x.ThenTheResponseBodyShouldBe("Some Product"))
.BDDfy();
}
[Fact]
public void should_return_response_201_with_simple_url()
{ {
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", 201, string.Empty)) this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", 201, string.Empty))
.And(x => x.GivenThereIsAConfiguration(new YamlConfiguration .And(x => x.GivenThereIsAConfiguration(new YamlConfiguration