mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-26 22:02:50 +08:00

* #298 initial hacking around better aggregation * #298 bit more hacking around * #298 abstraction over httpresponsemessage * #298 tidying up * #298 docs * #298 missed this
53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using Ocelot.Middleware;
|
|
using Ocelot.Responses;
|
|
using Shouldly;
|
|
using TestStack.BDDfy;
|
|
using Xunit;
|
|
|
|
namespace Ocelot.UnitTests.Headers
|
|
{
|
|
public class RemoveHeadersTests
|
|
{
|
|
private List<Header> _headers;
|
|
private readonly Ocelot.Headers.RemoveOutputHeaders _removeOutputHeaders;
|
|
private Response _result;
|
|
|
|
public RemoveHeadersTests()
|
|
{
|
|
_removeOutputHeaders = new Ocelot.Headers.RemoveOutputHeaders();
|
|
}
|
|
|
|
[Fact]
|
|
public void should_remove_header()
|
|
{
|
|
var headers = new List<Header>()
|
|
{
|
|
new Header("Transfer-Encoding", new List<string> {"chunked"})
|
|
};
|
|
|
|
this.Given(x => x.GivenAHttpContext(headers))
|
|
.When(x => x.WhenIRemoveTheHeaders())
|
|
.Then(x => x.TheHeaderIsNoLongerInTheContext())
|
|
.BDDfy();
|
|
}
|
|
|
|
private void GivenAHttpContext(List<Header> headers)
|
|
{
|
|
_headers = headers;
|
|
}
|
|
|
|
private void WhenIRemoveTheHeaders()
|
|
{
|
|
_result = _removeOutputHeaders.Remove(_headers);
|
|
}
|
|
|
|
private void TheHeaderIsNoLongerInTheContext()
|
|
{
|
|
_result.IsError.ShouldBeFalse();
|
|
_headers.ShouldNotContain(x => x.Key == "Transfer-Encoding");
|
|
_headers.ShouldNotContain(x => x.Key == "transfer-encoding");
|
|
}
|
|
}
|
|
}
|