Skip to content

Commit 2175439

Browse files
committed
Added unit tests for WaitStrategy.
1 parent fcbe81b commit 2175439

File tree

2 files changed

+58
-3
lines changed

2 files changed

+58
-3
lines changed

src/DotNet.Testcontainers.Tests/TestcontainersTests.cs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ namespace DotNet.Testcontainers.Tests
33
using System;
44
using System.IO;
55
using System.Net;
6+
using System.Threading;
67
using System.Threading.Tasks;
78
using DotNet.Testcontainers.Clients;
9+
using DotNet.Testcontainers.Core;
810
using DotNet.Testcontainers.Core.Builder;
911
using DotNet.Testcontainers.Core.Images;
1012
using Xunit;
@@ -260,5 +262,58 @@ public async Task VolumeAndEnvironment()
260262
Assert.Equal(dayOfWeek, text);
261263
}
262264
}
265+
266+
public class Strategy
267+
{
268+
[Fact]
269+
public async Task WaitWhile()
270+
{
271+
await WaitStrategy.WaitWhile(() =>
272+
{
273+
return false;
274+
});
275+
}
276+
277+
[Fact]
278+
public async Task WaitUntil()
279+
{
280+
await WaitStrategy.WaitUntil(() =>
281+
{
282+
return true;
283+
});
284+
}
285+
286+
[Fact]
287+
public async Task WaitWhileTimeout()
288+
{
289+
await Assert.ThrowsAsync<TimeoutException>(async () =>
290+
{
291+
await WaitStrategy.WaitWhile(
292+
() =>
293+
{
294+
return Wait100ms(true);
295+
}, timeout: 5);
296+
});
297+
}
298+
299+
[Fact]
300+
public async Task WaitUntilTimeout()
301+
{
302+
await Assert.ThrowsAsync<TimeoutException>(async () =>
303+
{
304+
await WaitStrategy.WaitUntil(
305+
() =>
306+
{
307+
return Wait100ms(false);
308+
}, timeout: 5);
309+
});
310+
}
311+
312+
private static bool Wait100ms(bool value)
313+
{
314+
Task.Delay(100);
315+
return value;
316+
}
317+
}
263318
}
264319
}

src/DotNet.Testcontainers/Core/Mapper/BaseConverter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ namespace DotNet.Testcontainers.Core.Mapper
22
{
33
internal abstract class BaseConverter<TSource, TTarget>
44
{
5-
private readonly string name;
6-
75
protected BaseConverter(string name)
86
{
9-
this.name = name;
7+
this.Name = name;
108
}
119

10+
public string Name { get; }
11+
1212
public abstract TTarget Convert(TSource source);
1313
}
1414
}

0 commit comments

Comments
 (0)