Skip to content

Commit 36064b1

Browse files
committed
use random port generator on tests from master
1 parent c75227d commit 36064b1

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

test/Ocelot.AcceptanceTests/HttpTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public HttpTests()
2525
[Fact]
2626
public void should_return_response_200_when_using_http_one()
2727
{
28-
const int port = 53219;
28+
var port = RandomPortFinder.GetRandomPort();
2929

3030
var configuration = new FileConfiguration
3131
{
@@ -63,7 +63,7 @@ public void should_return_response_200_when_using_http_one()
6363
[Fact]
6464
public void should_return_response_200_when_using_http_one_point_one()
6565
{
66-
const int port = 53279;
66+
var port = RandomPortFinder.GetRandomPort();
6767

6868
var configuration = new FileConfiguration
6969
{
@@ -101,7 +101,7 @@ public void should_return_response_200_when_using_http_one_point_one()
101101
[Fact]
102102
public void should_return_response_200_when_using_http_two_point_zero()
103103
{
104-
const int port = 53675;
104+
var port = RandomPortFinder.GetRandomPort();
105105

106106
var configuration = new FileConfiguration
107107
{
@@ -143,7 +143,7 @@ public void should_return_response_200_when_using_http_two_point_zero()
143143
[Fact]
144144
public void should_return_response_500_when_using_http_one_to_talk_to_server_running_http_two()
145145
{
146-
const int port = 53677;
146+
var port = RandomPortFinder.GetRandomPort();
147147

148148
var configuration = new FileConfiguration
149149
{
@@ -184,7 +184,7 @@ public void should_return_response_500_when_using_http_one_to_talk_to_server_run
184184
[Fact]
185185
public void should_return_response_200_when_using_http_two_to_talk_to_server_running_http_one_point_one()
186186
{
187-
const int port = 53679;
187+
var port = RandomPortFinder.GetRandomPort();
188188

189189
var configuration = new FileConfiguration
190190
{

test/Ocelot.AcceptanceTests/MethodTests.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public MethodTests()
2424
[Fact]
2525
public void should_return_response_200_when_get_converted_to_post()
2626
{
27+
var port = RandomPortFinder.GetRandomPort();
28+
2729
var configuration = new FileConfiguration
2830
{
2931
ReRoutes = new List<FileReRoute>
@@ -39,15 +41,15 @@ public void should_return_response_200_when_get_converted_to_post()
3941
new FileHostAndPort
4042
{
4143
Host = "localhost",
42-
Port = 53171,
44+
Port = port,
4345
},
4446
},
4547
DownstreamHttpMethod = "POST",
4648
},
4749
},
4850
};
4951

50-
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:53171/", "/", "POST"))
52+
this.Given(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{port}/", "/", "POST"))
5153
.And(x => _steps.GivenThereIsAConfiguration(configuration))
5254
.And(x => _steps.GivenOcelotIsRunning())
5355
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
@@ -58,6 +60,8 @@ public void should_return_response_200_when_get_converted_to_post()
5860
[Fact]
5961
public void should_return_response_200_when_get_converted_to_post_with_content()
6062
{
63+
var port = RandomPortFinder.GetRandomPort();
64+
6165
var configuration = new FileConfiguration
6266
{
6367
ReRoutes = new List<FileReRoute>
@@ -73,7 +77,7 @@ public void should_return_response_200_when_get_converted_to_post_with_content()
7377
new FileHostAndPort
7478
{
7579
Host = "localhost",
76-
Port = 53271,
80+
Port = port,
7781
},
7882
},
7983
DownstreamHttpMethod = "POST",
@@ -84,7 +88,7 @@ public void should_return_response_200_when_get_converted_to_post_with_content()
8488
const string expected = "here is some content";
8589
var httpContent = new StringContent(expected);
8690

87-
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:53271/", "/", "POST"))
91+
this.Given(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{port}/", "/", "POST"))
8892
.And(x => _steps.GivenThereIsAConfiguration(configuration))
8993
.And(x => _steps.GivenOcelotIsRunning())
9094
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/", httpContent))
@@ -96,6 +100,8 @@ public void should_return_response_200_when_get_converted_to_post_with_content()
96100
[Fact]
97101
public void should_return_response_200_when_get_converted_to_get_with_content()
98102
{
103+
var port = RandomPortFinder.GetRandomPort();
104+
99105
var configuration = new FileConfiguration
100106
{
101107
ReRoutes = new List<FileReRoute>
@@ -111,7 +117,7 @@ public void should_return_response_200_when_get_converted_to_get_with_content()
111117
new FileHostAndPort
112118
{
113119
Host = "localhost",
114-
Port = 53272,
120+
Port = port,
115121
},
116122
},
117123
DownstreamHttpMethod = "GET",
@@ -122,7 +128,7 @@ public void should_return_response_200_when_get_converted_to_get_with_content()
122128
const string expected = "here is some content";
123129
var httpContent = new StringContent(expected);
124130

125-
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:53272/", "/", "GET"))
131+
this.Given(x => x.GivenThereIsAServiceRunningOn($"http://localhost:{port}/", "/", "GET"))
126132
.And(x => _steps.GivenThereIsAConfiguration(configuration))
127133
.And(x => _steps.GivenOcelotIsRunning())
128134
.When(x => _steps.WhenIPostUrlOnTheApiGateway("/", httpContent))

0 commit comments

Comments
 (0)