mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-05-03 03:12:50 +08:00

* #274 added acceptance tests, need to work out failing unit tests but probably going to be a redesign where we hold a reference to the cookie container and empty it if needed * #274 updated code coverage value * #274 offloaded cache logic to builder in preparation for adding state * #274 hacked something together but this is not right approach * #274 updated defaults and docs * #274 updated code coverage
73 lines
2.5 KiB
C#
73 lines
2.5 KiB
C#
using Ocelot.Configuration;
|
|
using Ocelot.Configuration.Creator;
|
|
using Ocelot.Configuration.File;
|
|
using Shouldly;
|
|
using TestStack.BDDfy;
|
|
using Xunit;
|
|
|
|
namespace Ocelot.UnitTests.Configuration
|
|
{
|
|
public class HttpHandlerOptionsCreatorTests
|
|
{
|
|
private readonly IHttpHandlerOptionsCreator _httpHandlerOptionsCreator;
|
|
private FileReRoute _fileReRoute;
|
|
private HttpHandlerOptions _httpHandlerOptions;
|
|
|
|
public HttpHandlerOptionsCreatorTests()
|
|
{
|
|
_httpHandlerOptionsCreator = new HttpHandlerOptionsCreator();
|
|
}
|
|
|
|
[Fact]
|
|
public void should_create_options_with_useCookie_false_and_allowAutoRedirect_true_as_default()
|
|
{
|
|
var fileReRoute = new FileReRoute();
|
|
var expectedOptions = new HttpHandlerOptions(false, false, false);
|
|
|
|
this.Given(x => GivenTheFollowing(fileReRoute))
|
|
.When(x => WhenICreateHttpHandlerOptions())
|
|
.Then(x => ThenTheFollowingOptionsReturned(expectedOptions))
|
|
.BDDfy();
|
|
}
|
|
|
|
[Fact]
|
|
public void should_create_options_with_specified_useCookie_and_allowAutoRedirect()
|
|
{
|
|
var fileReRoute = new FileReRoute
|
|
{
|
|
HttpHandlerOptions = new FileHttpHandlerOptions
|
|
{
|
|
AllowAutoRedirect = false,
|
|
UseCookieContainer = false,
|
|
UseTracing = false
|
|
}
|
|
};
|
|
|
|
var expectedOptions = new HttpHandlerOptions(false, false, false);
|
|
|
|
this.Given(x => GivenTheFollowing(fileReRoute))
|
|
.When(x => WhenICreateHttpHandlerOptions())
|
|
.Then(x => ThenTheFollowingOptionsReturned(expectedOptions))
|
|
.BDDfy();
|
|
}
|
|
|
|
private void GivenTheFollowing(FileReRoute fileReRoute)
|
|
{
|
|
_fileReRoute = fileReRoute;
|
|
}
|
|
|
|
private void WhenICreateHttpHandlerOptions()
|
|
{
|
|
_httpHandlerOptions = _httpHandlerOptionsCreator.Create(_fileReRoute);
|
|
}
|
|
|
|
private void ThenTheFollowingOptionsReturned(HttpHandlerOptions expected)
|
|
{
|
|
_httpHandlerOptions.ShouldNotBeNull();
|
|
_httpHandlerOptions.AllowAutoRedirect.ShouldBe(expected.AllowAutoRedirect);
|
|
_httpHandlerOptions.UseCookieContainer.ShouldBe(expected.UseCookieContainer);
|
|
_httpHandlerOptions.UseTracing.ShouldBe(expected.UseTracing);
|
|
}
|
|
}
|
|
}
|