public void PartNameTest() { const string txt = "`Name`"; using (var scan = new CompactProfileScanner(txt)) { Assert.AreEqual(TokenType.Delimiter, scan.ScanTokenType(), "Verify and skip over delimiter"); Assert.AreEqual(TokenType.Name, scan.ScanTokenType()); Assert.AreEqual("Name", scan.ScanName(), "Should be the unqualified name"); Assert.AreEqual(TokenType.Delimiter, scan.ScanTokenType()); } }
public void LookupTest() { const string txt = "`%Class.Name=SubClass.Name:Lookup 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("L", scan.Current.ToString(CultureInfo.InvariantCulture), "Should now be in the body of the lookup"); } }
public void ConditionTest() { const string txt = "`?Class.Name='Class':Condition text`]"; using (var scan = new CompactProfileScanner(txt)) { Assert.AreEqual(TokenType.Delimiter, scan.ScanTokenType(), "Verify and skip over delimiter"); Assert.AreEqual(TokenType.Condition, scan.ScanTokenType()); Assert.AreEqual("Class.Name='Class'", scan.ScanCondition(), "Should be the condition"); Assert.AreEqual("C", scan.Current.ToString(CultureInfo.InvariantCulture), "Should now be in the body of the condition"); } }
public void SegmentClassTest() { const string txt = "`[Class>:Segment text`]"; using (var scan = new CompactProfileScanner(txt)) { Assert.AreEqual(TokenType.Delimiter, scan.ScanTokenType(), "Verify and skip over delimiter"); Assert.AreEqual(TokenType.Segment, scan.ScanTokenType()); Assert.AreEqual("Class>", scan.ScanSegmentClass(), "Should be the segement class"); Assert.AreEqual("S", scan.Current.ToString(CultureInfo.InvariantCulture), "Should now be on the body of the segment"); } }
internal void ScanPartialBody(int classId, GenSegBody body, GenContainerFragmentBase parentContainer, ContainerFragment containerFragment, out TokenType t) { FragmentBody = IsPrimary ? containerFragment.Body() : containerFragment.SecondaryBody(); GenTextBlock textBlock = null; var s = Scan.ScanText(); if (Scan.Eof) { if (s.Length > 0) { GenCompactProfileParser.AddText(parentContainer, FragmentBody, ref textBlock, s, GenDataDef, IsPrimary); } t = TokenType.Unknown; return; } if (s.Length > 0) { GenCompactProfileParser.AddText(parentContainer, FragmentBody, ref textBlock, s, GenDataDef, IsPrimary); } t = Scan.ScanTokenType(); while (!Scan.Eof && t != TokenType.Close && t != TokenType.Secondary && t != TokenType.Unknown) { if (t != TokenType.Name && textBlock != null) { textBlock = null; } var frag = GenCompactProfileParser.ScanFragment(classId, ref t, out s, parentContainer, FragmentBody, ref textBlock, IsPrimary); if (t != TokenType.Name) { AddFragment(body, frag); } if (s.Length > 0) { GenCompactProfileParser.AddText(parentContainer, FragmentBody, ref textBlock, s, GenDataDef, IsPrimary); } t = Scan.ScanTokenType(); } }
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()); } }