Skip to content

Commit

Permalink
use random port generator on tests from master
Browse files Browse the repository at this point in the history
  • Loading branch information
TomPallister committed Mar 11, 2020
1 parent c75227d commit 36064b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
10 changes: 5 additions & 5 deletions test/Ocelot.AcceptanceTests/HttpTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public HttpTests()
[Fact]
public void should_return_response_200_when_using_http_one()
{
const int port = 53219;
var port = RandomPortFinder.GetRandomPort();

var configuration = new FileConfiguration
{
Expand Down Expand Up @@ -63,7 +63,7 @@ public void should_return_response_200_when_using_http_one()
[Fact]
public void should_return_response_200_when_using_http_one_point_one()
{
const int port = 53279;
var port = RandomPortFinder.GetRandomPort();

var configuration = new FileConfiguration
{
Expand Down Expand Up @@ -101,7 +101,7 @@ public void should_return_response_200_when_using_http_one_point_one()
[Fact]
public void should_return_response_200_when_using_http_two_point_zero()
{
const int port = 53675;
var port = RandomPortFinder.GetRandomPort();

var configuration = new FileConfiguration
{
Expand Down Expand Up @@ -143,7 +143,7 @@ public void should_return_response_200_when_using_http_two_point_zero()
[Fact]
public void should_return_response_500_when_using_http_one_to_talk_to_server_running_http_two()
{
const int port = 53677;
var port = RandomPortFinder.GetRandomPort();

var configuration = new FileConfiguration
{
Expand Down Expand Up @@ -184,7 +184,7 @@ public void should_return_response_500_when_using_http_one_to_talk_to_server_run
[Fact]
public void should_return_response_200_when_using_http_two_to_talk_to_server_running_http_one_point_one()
{
const int port = 53679;
var port = RandomPortFinder.GetRandomPort();

var configuration = new FileConfiguration
{
Expand Down
18 changes: 12 additions & 6 deletions test/Ocelot.AcceptanceTests/MethodTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public MethodTests()
[Fact]
public void should_return_response_200_when_get_converted_to_post()
{
var port = RandomPortFinder.GetRandomPort();

var configuration = new FileConfiguration
{
ReRoutes = new List<FileReRoute>
Expand All @@ -39,15 +41,15 @@ public void should_return_response_200_when_get_converted_to_post()
new FileHostAndPort
{
Host = "localhost",
Port = 53171,
Port = port,
},
},
DownstreamHttpMethod = "POST",
},
},
};

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("/"))
Expand All @@ -58,6 +60,8 @@ public void should_return_response_200_when_get_converted_to_post()
[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>
Expand All @@ -73,7 +77,7 @@ public void should_return_response_200_when_get_converted_to_post_with_content()
new FileHostAndPort
{
Host = "localhost",
Port = 53271,
Port = port,
},
},
DownstreamHttpMethod = "POST",
Expand All @@ -84,7 +88,7 @@ public void should_return_response_200_when_get_converted_to_post_with_content()
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))
Expand All @@ -96,6 +100,8 @@ public void should_return_response_200_when_get_converted_to_post_with_content()
[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>
Expand All @@ -111,7 +117,7 @@ public void should_return_response_200_when_get_converted_to_get_with_content()
new FileHostAndPort
{
Host = "localhost",
Port = 53272,
Port = port,
},
},
DownstreamHttpMethod = "GET",
Expand All @@ -122,7 +128,7 @@ public void should_return_response_200_when_get_converted_to_get_with_content()
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))
Expand Down

0 comments on commit 36064b1

Please sign in to comment.