public void CompactTokenTypeTest() { const string txt = "[{%;?@]`x~"; using (var scan = new CompactProfileScanner(txt)) { Assert.AreEqual(TokenType.Segment, scan.ScanTokenType()); scan.SkipChar(); Assert.AreEqual(TokenType.Block, scan.ScanTokenType()); scan.SkipChar(); Assert.AreEqual(TokenType.Lookup, scan.ScanTokenType()); scan.SkipChar(); Assert.AreEqual(TokenType.Secondary, scan.ScanTokenType()); scan.SkipChar(); Assert.AreEqual(TokenType.Condition, scan.ScanTokenType()); scan.SkipChar(); Assert.AreEqual(TokenType.Function, scan.ScanTokenType()); scan.SkipChar(); Assert.AreEqual(TokenType.Close, scan.ScanTokenType()); scan.SkipChar(); Assert.AreEqual(TokenType.Delimiter, scan.ScanTokenType()); // Automatically skipped Assert.AreEqual(TokenType.Name, scan.ScanTokenType()); scan.SkipChar(); Assert.IsFalse(scan.Eof); Assert.AreEqual(TokenType.Unknown, scan.ScanTokenType()); scan.SkipChar(); Assert.IsTrue(scan.Eof); Assert.AreEqual(TokenType.Unknown, scan.ScanTokenType()); } }
public void EofTest() { using (var scan = new CompactProfileScanner("")) { Assert.IsTrue(scan.Eof); scan.SkipChar(); Assert.AreEqual(ScanReader.EofChar, scan.Current, "Scan past EOF"); } }
public void NoMatchTest() { const string txt = "`%Class.Name=SubClass.Name:`;No Match text`]"; using (var scan = new CompactProfileScanner(txt)) { Assert.AreEqual(TokenType.Delimiter, scan.ScanTokenType(), "Verify and skip over delimiter"); Assert.AreEqual(TokenType.Lookup, scan.ScanTokenType()); Assert.AreEqual("Class.Name=SubClass.Name", scan.ScanLookup(), "Should be the lookup condition"); Assert.AreEqual(TokenType.Delimiter, scan.ScanTokenType(), "Verify and skip over delimiter"); Assert.AreEqual(TokenType.Secondary, scan.ScanTokenType(), "Should be on the secondary token"); scan.SkipChar(); Assert.AreEqual("N", scan.Current.ToString(CultureInfo.InvariantCulture), "Should now be in the body of the lookup"); } }