Skip to content

Commit

Permalink
testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
DomCR committed Apr 29, 2024
1 parent 5ef067c commit 4b4bd97
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions CSUtilities.Tests/Extensions/StringExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@ namespace CSUtilities.Tests.Extensions
{
public class StringExtensionsTests
{
[Fact]
public void IsNullOrEmptyTest()
public static TheoryData<string> NullEmpy { get; } = new();

static StringExtensionsTests()
{
string n = null;
Assert.True(n.IsNullOrEmpty());
NullEmpy.Add(null);
NullEmpy.Add(string.Empty);
}

[Fact]
public void TrowIfNullOrEmptyTest()
[Theory]
[MemberData(nameof(NullEmpy))]
public void IsNullOrEmptyTest(string value)
{
string n = null;

Assert.Throws<ArgumentException>(n.TrowIfNullOrEmpty);
Assert.Throws<ArgumentException>(() => n.TrowIfNullOrEmpty("Message in case of null or empty"));

string empty = string.Empty;
Assert.True(value.IsNullOrEmpty());
}

Assert.Throws<ArgumentException>(empty.TrowIfNullOrEmpty);
Assert.Throws<ArgumentException>(() => empty.TrowIfNullOrEmpty("Message in case of null or empty"));
[Theory]
[MemberData(nameof(NullEmpy))]
public void TrowIfNullOrEmptyTest(string value)
{
Assert.Throws<ArgumentException>(value.TrowIfNullOrEmpty);
Assert.Throws<ArgumentException>(() => value.TrowIfNullOrEmpty("Message in case of null or empty"));
}
}
}

0 comments on commit 4b4bd97

Please sign in to comment.