Skip to content

Commit 6612fb6

Browse files
authored
test: Extended ThrowIfNullOrEmpty tests (#393)
* test: Extended `ThrowIfNullOrEmpty` tests * fix(test): Wrong Exception Type
1 parent 7755da5 commit 6612fb6

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/NetEvolve.Arguments.Tests.Unit/ArgumentTests_ThrowIfNullOrEmpty.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using System;
44
using System.Collections.Generic;
5+
using System.Threading.Tasks;
56
using TUnit.Assertions.Extensions;
67

78
public sealed partial class ArgumentTests
@@ -58,6 +59,28 @@ public void ThrowIfNullOrEmpty_WhenIEnumerableNull_ThrowsArgumentNullException()
5859
_ = Assert.Throws<ArgumentNullException>(nameof(argument), Act);
5960
}
6061

62+
[Test]
63+
[MethodDataSource(nameof(ThrowIfNullOrEmptyEnumerableData))]
64+
public void ThrowIfNullOrEmpty_WhenIEnumerableEmpty_ThrowsArgumentException(IEnumerable<string>? argument)
65+
{
66+
// Act
67+
void Act() => Argument.ThrowIfNullOrEmpty(argument);
68+
69+
// Assert
70+
_ = Assert.Throws<ArgumentException>(nameof(argument), Act);
71+
}
72+
73+
[Test]
74+
[MethodDataSource(nameof(ThrowIfNullOrEmptyEnumerableWithData))]
75+
public async Task ThrowIfNullOrEmpty_WhenIEnumerableEmpty_Expected(IEnumerable<string>? argument)
76+
{
77+
// Act
78+
Argument.ThrowIfNullOrEmpty(argument);
79+
80+
// Assert
81+
_ = await Assert.That(argument).IsNotNull().And.IsNotEmpty();
82+
}
83+
6184
public static IEnumerable<IEnumerable<string>> ThrowIfNullOrEmptyEnumerableData =>
6285
[Array.Empty<string>(), new List<string>(), new HashSet<string>()];
6386

0 commit comments

Comments
 (0)