1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-09 23:45:42 +00:00

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

View File

@ -22,6 +22,38 @@ public class TimeSpanParserTests
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]
public void TryParse_ShouldReturnFalse_GivenNull()
{