From f30c0526732121c0f8b5be94af68302baa930359 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Thu, 30 Mar 2023 20:44:45 +0100 Subject: [PATCH] test: 100% coverage for TimeSpanParser.TryParse --- X10D.Tests/src/Time/TimeSpanParserTests.cs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/X10D.Tests/src/Time/TimeSpanParserTests.cs b/X10D.Tests/src/Time/TimeSpanParserTests.cs index 04149c5..f1ba85c 100644 --- a/X10D.Tests/src/Time/TimeSpanParserTests.cs +++ b/X10D.Tests/src/Time/TimeSpanParserTests.cs @@ -22,6 +22,38 @@ public class TimeSpanParserTests Assert.AreEqual(default, timeSpan); } + [TestMethod] + public void TryParse_ShouldReturnFalse_GivenEmptySpan() + { + bool result = TimeSpanParser.TryParse(ReadOnlySpan.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() {