Exemplo n.º 1
0
        public void TryParseExplicitDate(string inputStr, string expectedDateStr)
        {
            DateTime expected = DateTime.Parse(expectedDateStr);

            bool success = DateMatchUtils.TryMatchDate(inputStr, out DateTime actual);

            Assert.True(success);
            Assert.Equal(expected, actual);
        }
Exemplo n.º 2
0
        public void TryParseRelativeDate(string inputStr, string currentDateStr, string expectedDateStr)
        {
            DateTime expected    = DateTime.Parse(expectedDateStr);
            DateTime currentDate = DateTime.Parse(currentDateStr);

            bool success = DateMatchUtils.TryMatchDate(inputStr, currentDate, out DateTime actual);

            Assert.True(success);
            Assert.Equal(expected, actual);
        }
Exemplo n.º 3
0
        public void TryParseYesterday()
        {
            DateTime currentDate = DateTime.Parse("01/02/2020");
            DateTime expected    = DateTime.Parse("01/01/2020");

            bool success = DateMatchUtils.TryMatchDate("yesterday", currentDate, out DateTime actual);

            Assert.True(success);
            Assert.Equal(expected, actual);
        }
Exemplo n.º 4
0
 public override TokenMatchResult Matches(string[] inputTokens, int startIdx)
 {
     DateMatchUtils.TryMatchDate(this, CurrentDate, inputTokens, startIdx, out TokenMatchResult result);
     return(result);
 }
Exemplo n.º 5
0
        public void TryParseDateFails(string inputStr)
        {
            bool success = DateMatchUtils.TryMatchDate(inputStr, out DateTime date);

            Assert.False(success);
        }