mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-10 03:45:41 +00:00
Update string.With*Alternative tests
This commit is contained in:
parent
4f99763a0a
commit
5509305c5a
@ -65,16 +65,31 @@ namespace X10D.Tests.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests for <see cref="StringExtensions.WithAlternative" />.
|
/// Tests <see cref="StringExtensions.WithEmptyAlternative" /> and
|
||||||
|
/// <see cref="StringExtensions.WithWhiteSpaceAlternative"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void WithAlternative()
|
public void WithAlternative()
|
||||||
{
|
{
|
||||||
Assert.AreEqual("Hello", "Hello".WithAlternative("Discarded"));
|
const string inputA = "Hello World";
|
||||||
Assert.AreEqual("Alternative", string.Empty.WithAlternative("Alternative"));
|
const string inputB = " ";
|
||||||
Assert.AreEqual(" ", " ".WithAlternative("Discarded"));
|
const string inputC = "";
|
||||||
Assert.AreEqual("Alternative", " ".WithAlternative("Alternative", true));
|
const string? inputD = null;
|
||||||
Assert.AreEqual("Alternative", ((string)null).WithAlternative("Alternative"));
|
const string alternative = "ALTERNATIVE";
|
||||||
|
|
||||||
|
string resultA = inputA.WithEmptyAlternative(alternative);
|
||||||
|
string resultB = inputB.WithEmptyAlternative(alternative);
|
||||||
|
string resultBWithWhitespace = inputB.WithWhiteSpaceAlternative(alternative);
|
||||||
|
string resultC = inputC.WithEmptyAlternative(alternative);
|
||||||
|
string resultD = inputD.WithEmptyAlternative(alternative);
|
||||||
|
|
||||||
|
Assert.ThrowsException<ArgumentNullException>(() => ((string?)null).WithEmptyAlternative(null!));
|
||||||
|
|
||||||
|
Assert.AreEqual(resultA, inputA);
|
||||||
|
Assert.AreEqual(resultB, inputB);
|
||||||
|
Assert.AreEqual(resultBWithWhitespace, alternative);
|
||||||
|
Assert.AreEqual(resultC, alternative);
|
||||||
|
Assert.AreEqual(resultD, alternative);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user