diff --git a/X10D.Tests/src/Time/TimeSpanParserTests.cs b/X10D.Tests/src/Time/TimeSpanParserTests.cs index b671070..04149c5 100644 --- a/X10D.Tests/src/Time/TimeSpanParserTests.cs +++ b/X10D.Tests/src/Time/TimeSpanParserTests.cs @@ -7,9 +7,26 @@ namespace X10D.Tests.Time; public class TimeSpanParserTests { [TestMethod] - public void TryParse_ShouldThrow_GivenNullString() + public void TryParse_ShouldReturnTrue_GivenWellFormedTimeSpan() { - string? value = null; - Assert.ThrowsException(() => TimeSpanParser.TryParse(value!, out _)); + bool result = TimeSpanParser.TryParse("3d6h", out TimeSpan timeSpan); + Assert.IsTrue(result); + Assert.AreEqual(TimeSpan.FromDays(3) + TimeSpan.FromHours(6), timeSpan); + } + + [TestMethod] + public void TryParse_ShouldReturnFalse_GivenMalformedTimeSpan() + { + bool result = TimeSpanParser.TryParse("asdf", out TimeSpan timeSpan); + Assert.IsFalse(result); + Assert.AreEqual(default, timeSpan); + } + + [TestMethod] + public void TryParse_ShouldReturnFalse_GivenNull() + { + bool result = TimeSpanParser.TryParse(null, out TimeSpan timeSpan); + Assert.IsFalse(result); + Assert.AreEqual(default, timeSpan); } }