Skip to content

Commit 301466b

Browse files
committed
test setup
1 parent b72e2b0 commit 301466b

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/samples/WorkflowCore.TestSample01/WorkflowCore.TestSample01.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>

test/Docker.Testify/DockerSetup.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public abstract class DockerSetup : IDisposable
3030
protected readonly DockerClient docker;
3131
protected string containerId;
3232

33-
private static object Lock = new object();
33+
private static HashSet<int> UsedPorts = new HashSet<int>();
3434

3535
protected DockerSetup()
3636
{
@@ -124,7 +124,7 @@ public void Dispose()
124124

125125
private int GetFreePort()
126126
{
127-
lock (Lock)
127+
lock (UsedPorts)
128128
{
129129
const int startRange = 1000;
130130
const int endRange = 10000;
@@ -134,11 +134,13 @@ private int GetFreePort()
134134

135135
var result = startRange;
136136

137-
while (((tcpPorts.Any(x => x.Port == result)) || (udpPorts.Any(x => x.Port == result))) && result <= endRange)
137+
while (((tcpPorts.Any(x => x.Port == result)) || (udpPorts.Any(x => x.Port == result))) && result <= endRange && !UsedPorts.Contains(result))
138138
result++;
139139

140140
if (result > endRange)
141141
throw new PortsInUseException();
142+
143+
UsedPorts.Add(result);
142144

143145
return result;
144146
}

0 commit comments

Comments
 (0)