use random port generator on tests from master

This commit is contained in:
TomPallister
2020-03-11 20:09:36 +00:00
parent c75227d5b8
commit 36064b13d0
2 changed files with 17 additions and 11 deletions

View File

@ -24,6 +24,8 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_response_200_when_get_converted_to_post()
{
var port = RandomPortFinder.GetRandomPort();
var configuration = new FileConfiguration
{
ReRoutes = new List<FileReRoute>
@ -39,7 +41,7 @@ namespace Ocelot.AcceptanceTests
new FileHostAndPort
{
Host = "localhost",
Port = 53171,
Port = port,
},
},
DownstreamHttpMethod = "POST",
@ -47,7 +49,7 @@ namespace Ocelot.AcceptanceTests
},
};
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:53171/", "/", "POST"))
this.Given(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{port}/", "/", "POST"))
.And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
@ -58,6 +60,8 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_response_200_when_get_converted_to_post_with_content()
{
var port = RandomPortFinder.GetRandomPort();
var configuration = new FileConfiguration
{
ReRoutes = new List<FileReRoute>
@ -73,7 +77,7 @@ namespace Ocelot.AcceptanceTests
new FileHostAndPort
{
Host = "localhost",
Port = 53271,
Port = port,
},
},
DownstreamHttpMethod = "POST",
@ -84,7 +88,7 @@ namespace Ocelot.AcceptanceTests
const string expected = "here is some content";
var httpContent = new StringContent(expected);
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:53271/", "/", "POST"))
this.Given(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{port}/", "/", "POST"))
.And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/", httpContent))
@ -96,6 +100,8 @@ namespace Ocelot.AcceptanceTests
[Fact]
public void should_return_response_200_when_get_converted_to_get_with_content()
{
var port = RandomPortFinder.GetRandomPort();
var configuration = new FileConfiguration
{
ReRoutes = new List<FileReRoute>
@ -111,7 +117,7 @@ namespace Ocelot.AcceptanceTests
new FileHostAndPort
{
Host = "localhost",
Port = 53272,
Port = port,
},
},
DownstreamHttpMethod = "GET",
@ -122,7 +128,7 @@ namespace Ocelot.AcceptanceTests
const string expected = "here is some content";
var httpContent = new StringContent(expected);
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:53272/", "/", "GET"))
this.Given(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{port}/", "/", "GET"))
.And(x => _steps.GivenThereIsAConfiguration(configuration))
.And(x => _steps.GivenOcelotIsRunning())
.When(x => _steps.WhenIPostUrlOnTheApiGateway("/", httpContent))