public void TestAnyAndIfElseFailed() { var ifElseContainer = new Sequence(); ifElseContainer .If(new StringUnit("lexem")); ifElseContainer .Else(new StringUnit("xxx")); var anyContainer = new ContainerAnyUnits(); anyContainer.Add(ifElseContainer); anyContainer.Add(new StringUnit("aaa")); var sequence = new Sequence().AddIgnoreSymbol(' '); UnitError error = null; sequence .Add(anyContainer) .Error(x => error = x); var result = sequence.DecodeLine("lexem xxx"); Assert.IsFalse(result); Assert.IsTrue(error != null); Assert.IsTrue(error.PositionInLine == 6); Assert.IsTrue(error.Unit.IsFirstSymbol(error.Line[error.PositionInLine])); }
public void TestAnyAndIfElse2Success() { //----------------------------------------------------------------- var ifElseContainer1 = new Sequence(); ifElseContainer1 .If(new StringUnit("lexem")); ifElseContainer1 .Else(new StringUnit("xxx")); var anyContainer = new ContainerAnyUnits(); anyContainer.Add(ifElseContainer1); //----------------------------------------------------------------- var ifElseContainer2 = new Sequence(); ifElseContainer2 .If(new StringUnit("aaa")); ifElseContainer2 .Else(new StringUnit("bbb")); //----------------------------------------------------------------- var sequence = new Sequence().AddIgnoreSymbol(' '); UnitError error = null; sequence .Add(anyContainer, ifElseContainer2) .Error(x => error = x); var result = sequence.DecodeLine("xxx bbb"); Assert.IsTrue(result); Assert.IsTrue(error == null); }