hacking around to get a POST acceptance test working, doesnt really mean anything tbh

This commit is contained in:
TomPallister
2016-09-13 19:34:53 +01:00
parent 72cec38c0e
commit 8423199754
3 changed files with 39 additions and 6 deletions

View File

@ -33,7 +33,7 @@ namespace Ocelot.AcceptanceTests
{
this.Given(x => x.GivenThereIsAConfiguration(new Configuration()))
.And(x => x.GivenTheApiGatewayIsRunning())
.When(x => x.WhenIRequestTheUrlOnTheApiGateway("/"))
.When(x => x.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => x.ThenTheStatusCodeShouldBe(HttpStatusCode.NotFound))
.BDDfy();
}
@ -54,12 +54,33 @@ namespace Ocelot.AcceptanceTests
}
}))
.And(x => x.GivenTheApiGatewayIsRunning())
.When(x => x.WhenIRequestTheUrlOnTheApiGateway("/"))
.When(x => x.WhenIGetUrlOnTheApiGateway("/"))
.Then(x => x.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
.And(x => x.ThenTheResponseBodyShouldBe("Hello from Laura"))
.BDDfy();
}
[Fact]
public void should_return_response_201()
{
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879"))
.And(x => x.GivenThereIsAConfiguration(new Configuration
{
ReRoutes = new List<ReRoute>
{
new ReRoute
{
DownstreamTemplate = "http://localhost:51879/",
UpstreamTemplate = "/"
}
}
}))
.And(x => x.GivenTheApiGatewayIsRunning())
.When(x => x.WhenIPostUrlOnTheApiGateway("/"))
.Then(x => x.ThenTheStatusCodeShouldBe(HttpStatusCode.Created))
.BDDfy();
}
/// <summary>
/// This is annoying cos it should be in the constructor but we need to set up the yaml file before calling startup so its a step.
/// </summary>
@ -91,11 +112,16 @@ namespace Ocelot.AcceptanceTests
_fakeService.Start(url);
}
private void WhenIRequestTheUrlOnTheApiGateway(string url)
private void WhenIGetUrlOnTheApiGateway(string url)
{
_response = _client.GetAsync(url).Result;
}
private void WhenIPostUrlOnTheApiGateway(string url)
{
_response = _client.PostAsync(url, new StringContent(string.Empty)).Result;
}
private void ThenTheStatusCodeShouldBe(HttpStatusCode expectedHttpStatusCode)
{
_response.StatusCode.ShouldBe(expectedHttpStatusCode);