Esempio n. 1
0
 public void ParseToOnlyTest()
 {
     try
     {
         var range = FuzzyDateRange.Parse("-2019");
         Assert.IsFalse(range.From.Year.HasValue);
         Assert.AreEqual(2019, range.To.Year.Value);
     }
     catch (Exception ex)
     {
         Assert.Fail($"Expect no exception, but got {ex.Message}");
     }
 }
Esempio n. 2
0
 public void ParseDelineatorOnlyTest()
 {
     try
     {
         var range = FuzzyDateRange.Parse("-");
         Assert.IsFalse(range.From.Year.HasValue);
         Assert.IsFalse(range.To.Year.HasValue);
     }
     catch (Exception ex)
     {
         Assert.Fail($"Expect no exception, but got {ex.Message}");
     }
 }
Esempio n. 3
0
 public void ParseBothTest()
 {
     try
     {
         var range = FuzzyDateRange.Parse("10/2019-11/15/2019");
         Assert.AreEqual(2019, range.From.Year.Value);
         Assert.AreEqual(10, range.From.Month.Value);
         Assert.IsFalse(range.From.Day.HasValue);
         Assert.AreEqual(2019, range.To.Year.Value);
         Assert.AreEqual(11, range.To.Month.Value);
         Assert.AreEqual(15, range.To.Day.Value);
     }
     catch (Exception ex)
     {
         Assert.Fail($"Expect no exception, but got {ex.Message}");
     }
 }
Esempio n. 4
0
 public void ParseFromInvalidDateTest()
 {
     Assert.ThrowsException <BadDateFormatException>(() => _ = FuzzyDateRange.Parse("left-right"));
 }
Esempio n. 5
0
 public void ParseFromInvalidRangeTest()
 {
     Assert.ThrowsException <BadDateRangeFormatException>(() => _ = FuzzyDateRange.Parse("2019"));
 }