test: 100% coverage for TimeSpanParser.TryParse

This commit is contained in:
Oliver Booth 2023-03-30 20:44:45 +01:00
parent 628ead1ebb
commit f30c052673
No known key found for this signature in database
GPG Key ID: 20BEB9DC87961025
1 changed files with 32 additions and 0 deletions

View File

@ -22,6 +22,38 @@ public class TimeSpanParserTests
Assert.AreEqual(default, timeSpan); Assert.AreEqual(default, timeSpan);
} }
[TestMethod]
public void TryParse_ShouldReturnFalse_GivenEmptySpan()
{
bool result = TimeSpanParser.TryParse(ReadOnlySpan<char>.Empty, out TimeSpan timeSpan);
Assert.IsFalse(result);
Assert.AreEqual(default, timeSpan);
}
[TestMethod]
public void TryParse_ShouldReturnFalse_GivenWhiteSpaceSpan()
{
bool result = TimeSpanParser.TryParse(" ".AsSpan(), out TimeSpan timeSpan);
Assert.IsFalse(result);
Assert.AreEqual(default, timeSpan);
}
[TestMethod]
public void TryParse_ShouldReturnFalse_GivenEmptyString()
{
bool result = TimeSpanParser.TryParse(string.Empty, out TimeSpan timeSpan);
Assert.IsFalse(result);
Assert.AreEqual(default, timeSpan);
}
[TestMethod]
public void TryParse_ShouldReturnFalse_GivenWhiteSpaceString()
{
bool result = TimeSpanParser.TryParse(" ", out TimeSpan timeSpan);
Assert.IsFalse(result);
Assert.AreEqual(default, timeSpan);
}
[TestMethod] [TestMethod]
public void TryParse_ShouldReturnFalse_GivenNull() public void TryParse_ShouldReturnFalse_GivenNull()
{ {