Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using TUnit.Assertions.Extensions;

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

[Test]
[MethodDataSource(nameof(ThrowIfNullOrEmptyEnumerableData))]
public void ThrowIfNullOrEmpty_WhenIEnumerableEmpty_ThrowsArgumentException(IEnumerable<string>? argument)
{
// Act
void Act() => Argument.ThrowIfNullOrEmpty(argument);

// Assert
_ = Assert.Throws<ArgumentException>(nameof(argument), Act);
}

[Test]
[MethodDataSource(nameof(ThrowIfNullOrEmptyEnumerableWithData))]
public async Task ThrowIfNullOrEmpty_WhenIEnumerableEmpty_Expected(IEnumerable<string>? argument)
{
// Act
Argument.ThrowIfNullOrEmpty(argument);

// Assert
_ = await Assert.That(argument).IsNotNull().And.IsNotEmpty();
}

public static IEnumerable<IEnumerable<string>> ThrowIfNullOrEmptyEnumerableData =>
[Array.Empty<string>(), new List<string>(), new HashSet<string>()];

Expand Down
Loading