#298 initial hacking around better aggregation (#310)

* #298 initial hacking around better aggregation

* #298 bit more hacking around

* #298 abstraction over httpresponsemessage

* #298 tidying up

* #298 docs

* #298 missed this
This commit is contained in:
Tom Pallister
2018-04-12 17:35:04 +01:00
committed by GitHub
parent 982eebfc74
commit a15f75dda8
63 changed files with 1203 additions and 410 deletions

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using Ocelot.Middleware;
using Ocelot.Middleware.Multiplexer;
namespace Ocelot.UnitTests.Responder
{
@ -40,8 +41,7 @@ namespace Ocelot.UnitTests.Responder
[Fact]
public void should_not_return_any_errors()
{
this.Given(x => x.GivenTheHttpResponseMessageIs(new HttpResponseMessage()))
.And(x => x.GivenThereAreNoPipelineErrors())
this.Given(x => x.GivenTheHttpResponseMessageIs(new DownstreamResponse(new HttpResponseMessage())))
.When(x => x.WhenICallTheMiddleware())
.Then(x => x.ThenThereAreNoErrors())
.BDDfy();
@ -50,7 +50,7 @@ namespace Ocelot.UnitTests.Responder
[Fact]
public void should_return_any_errors()
{
this.Given(x => x.GivenTheHttpResponseMessageIs(new HttpResponseMessage()))
this.Given(x => x.GivenTheHttpResponseMessageIs(new DownstreamResponse(new HttpResponseMessage())))
.And(x => x.GivenThereArePipelineErrors(new UnableToFindDownstreamRouteError("/path", "GET")))
.When(x => x.WhenICallTheMiddleware())
.Then(x => x.ThenThereAreNoErrors())
@ -62,16 +62,11 @@ namespace Ocelot.UnitTests.Responder
_middleware.Invoke(_downstreamContext).GetAwaiter().GetResult();
}
private void GivenTheHttpResponseMessageIs(HttpResponseMessage response)
private void GivenTheHttpResponseMessageIs(DownstreamResponse response)
{
_downstreamContext.DownstreamResponse = response;
}
private void GivenThereAreNoPipelineErrors()
{
_downstreamContext.Errors = new List<Error>();
}
private void ThenThereAreNoErrors()
{
//todo a better assert?
@ -79,7 +74,7 @@ namespace Ocelot.UnitTests.Responder
private void GivenThereArePipelineErrors(Error error)
{
_downstreamContext.Errors = new List<Error>(){error};
_downstreamContext.Errors.Add(error);
}
}
}