refactoring acceptance tests..they need some tlc

This commit is contained in:
TomPallister
2016-10-19 21:28:55 +01:00
parent ab5d7fa33d
commit 9798cf01e5
10 changed files with 297 additions and 460 deletions

View File

@ -11,7 +11,6 @@ using Ocelot.ManualTest;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
using YamlDotNet.Serialization;
namespace Ocelot.AcceptanceTests
{
@ -20,22 +19,19 @@ namespace Ocelot.AcceptanceTests
private TestServer _ocelotServer;
private HttpClient _ocelotClient;
private HttpResponseMessage _response;
private readonly string _configurationPath;
private IWebHost _servicebuilder;
// Sadly we need to change this when we update the netcoreapp version to make the test update the config correctly
private double _netCoreAppVersion = 1.4;
private readonly Steps _steps;
public ReturnsErrorTests()
{
_configurationPath = $"./bin/Debug/netcoreapp{_netCoreAppVersion}/configuration.yaml";
_steps = new Steps();
}
[Fact]
public void should_return_response_200_and_foward_claim_as_header()
{
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:53876"))
.And(x => x.GivenThereIsAConfiguration(new YamlConfiguration
.And(x => _steps.GivenThereIsAConfiguration(new YamlConfiguration
{
ReRoutes = new List<YamlReRoute>
{
@ -74,21 +70,6 @@ namespace Ocelot.AcceptanceTests
_ocelotClient = _ocelotServer.CreateClient();
}
private void GivenThereIsAConfiguration(YamlConfiguration yamlConfiguration)
{
var serializer = new Serializer();
if (File.Exists(_configurationPath))
{
File.Delete(_configurationPath);
}
using (TextWriter writer = File.CreateText(_configurationPath))
{
serializer.Serialize(writer, yamlConfiguration);
}
}
private void GivenThereIsAServiceRunningOn(string url)
{
_servicebuilder = new WebHostBuilder()