Esempio n. 1
0
        public void TryParseDateRangeArg_2(string text)
        {
            string[] tokens = CommandParser.Tokenize(text);
            RangeArgumentToken <DateTime> token = new RangeArgumentToken <DateTime>("arg", false, DateMatchUtils.TryMatchDate);

            var result = token.Matches(tokens, 0);

            Range <DateTime> range;
            bool             argValueExists = result.TryGetArgValue(token, out range);


            Assert.True(result.MatchOutcome == MatchOutcome.Full, "Outcome is not full match");
            Assert.True(argValueExists, "Argument value does not exist");
        }
Esempio n. 2
0
        [InlineData("( 3 , ]")]  //No second arg
        public void TryParseRange_Failure(string text)
        {
            string[] tokens = CommandParser.Tokenize(text);
            RangeArgumentToken <int> token = new RangeArgumentToken <int>("arg", false, int.TryParse);

            var result = token.Matches(tokens, 0);

            Range <int> range;
            bool        argValueExists = result.TryGetArgValue(token, out range);


            Assert.True(result.MatchOutcome == MatchOutcome.None, "Outcome is not full match. Test Case = " + text);
            Assert.False(argValueExists, "Argument value should not exist but does. Test Case = " + text);
        }
Esempio n. 3
0
        public void TryParseIntRangeArg(string text, int expectedStart, int expectedEnd)
        {
            string[] tokens = CommandParser.Tokenize(text);
            RangeArgumentToken <int> token = new RangeArgumentToken <int>("arg", false, int.TryParse);

            var result = token.Matches(tokens, 0);

            Range <int> range;
            bool        argValueExists = result.TryGetArgValue(token, out range);


            Assert.True(result.MatchOutcome == MatchOutcome.Full, "Outcome is not full match");
            Assert.True(argValueExists, "Argument value does not exist");
            Assert.Equal(expectedStart, range.From);
            Assert.Equal(expectedEnd, range.To);
        }
Esempio n. 4
0
        public void TryParseDateRangeArg(string[] tokens, string expectedStartStr, string expectedEndStr)
        {
            DateTime expectedStart = DateTime.Parse(expectedStartStr);
            DateTime expectedEnd   = DateTime.Parse(expectedEndStr);

            RangeArgumentToken <DateTime> token = new RangeArgumentToken <DateTime>("arg", false, DateMatchUtils.TryMatchDate);

            var result = token.Matches(tokens, 0);

            Range <DateTime> range;
            bool             argValueExists = result.TryGetArgValue(token, out range);


            Assert.True(result.MatchOutcome == MatchOutcome.Full, "Outcome is not full match");
            Assert.True(argValueExists, "Argument value does not exist");
            Assert.Equal(expectedStart, range.From);
            Assert.Equal(expectedEnd, range.To);
        }