Exemplo n.º 1
0
 public void MultipleTokensWithPartialMatches()
 {
     var tokens = new List<IToken> { new StringToken("hej"), new StringToken("hejsan") };
     var parseThis = "hej hejsan hej";
     var expected = new List<string> { "hej", "hejsan", "hej" };
     var parsed = new Tokenizer(tokens).Parse(parseThis);
     CollectionAssert.AreEqual(expected, parsed);
 }
Exemplo n.º 2
0
 public void MultipleTokensWithPartialMatches2()
 {
     var tokens = new List<IToken> { new StringToken("a"), new StringToken("ab"), new StringToken("abc"), new StringToken("abcd") };
     var parseThis = "aababcabcdabcaba";
     var expected = new List<string> { "a", "ab", "abc", "abcd", "abc", "ab", "a" };
     var parsed = new Tokenizer(tokens).Parse(parseThis);
     CollectionAssert.AreEqual(expected, parsed);
 }
Exemplo n.º 3
0
 public void MultipleTokensAppearsOnceEach()
 {
     var tokens = new List<IToken> { new StringToken("test"), new StringToken("hej") };
     var parseThis = "hej test";
     var expected = new List<string> { "hej", "test" };
     var parsed = new Tokenizer(tokens).Parse(parseThis);
     CollectionAssert.AreEqual(expected, parsed);
 }
Exemplo n.º 4
0
 public void IntegerLongerThanOneChar()
 {
     var tokens = new List<IToken> { new IntegerToken() };
     var parseThis = "12";
     var expected = new List<string> { "12" };
     var parsed = new Tokenizer(tokens).Parse(parseThis);
     CollectionAssert.AreEqual(expected, parsed);
 }
Exemplo n.º 5
0
 public void IntegerAndTextRespectsSpace()
 {
     var tokens = new List<IToken> { new StringToken("test"), new IntegerToken() };
     var parseThis = " 12 test ";
     var expected = new List<string> { "12", "test" };
     var parsed = new Tokenizer(tokens).Parse(parseThis);
     CollectionAssert.AreEqual(expected, parsed);
 }
Exemplo n.º 6
0
 public ScheduleParser()
 {
     _tokenizer = new Tokenizer();
     Add("every", "day", "month", "week", "year", "hour",
         "at", "@", ":",
         "st", "nd", "rd", "th",
         "last",
         "s",
         "and");
     Add(_days);
     _tokenizer.AddToken(new IntegerToken());
 }
Exemplo n.º 7
0
 public void SingleTokenAppearsOnce()
 {
     var tokens = new List<IToken> { new StringToken("test") };
     var parseThis = "test";
     var expected = new List<string> { "test" };
     var parsed = new Tokenizer(tokens).Parse(parseThis);
     CollectionAssert.AreEqual(expected, parsed);
 }
Exemplo n.º 8
0
 public void SpaceBetweenTextsSeperatesThem2()
 {
     var tokens = new List<IToken> { new StringToken("test"), new StringToken("testtest") };
     var parseThis = "testtest";
     var expected = new List<string> { "testtest" };
     var parsed = new Tokenizer(tokens).Parse(parseThis);
     CollectionAssert.AreEqual(expected, parsed);
 }
Exemplo n.º 9
0
 public void SpaceBetweenIntegersSeperatesThem()
 {
     var tokens = new List<IToken> { new IntegerToken() };
     var parseThis = " 12 1 ";
     var expected = new List<string> { "12", "1" };
     var parsed = new Tokenizer(tokens).Parse(parseThis);
     CollectionAssert.AreEqual(expected, parsed);
 }