public void AltTest() { var expr = new AltExpression(new[] { new StructureExpression("foo"), new StructureExpression("bar") }); var result = expr.Run(); Assert.Collection(result, item => { Assert.IsType <StructureResultTree>(item); Assert.Equal("foo", (item as StructureResultTree).Name); Assert.Collection((item as StructureResultTree).FirstChild, item => Assert.Null(item) ); Assert.Collection((item as StructureResultTree).NextSibling, item => Assert.Null(item) ); }, item => { Assert.IsType <StructureResultTree>(item); Assert.Equal("bar", (item as StructureResultTree).Name); Assert.Collection((item as StructureResultTree).FirstChild, item => Assert.Null(item) ); Assert.Collection((item as StructureResultTree).NextSibling, item => Assert.Null(item) ); } ); }
public void EmptyInput() { // Given var expression = new AltExpression( new TextExpression("x"), new TextExpression("y") ); // When var result = expression.Transform(""); // Then Assert.Null(result); }
public void MatchFirst() { // Given var expression = new AltExpression( new TextExpression("x"), new TextExpression("y") ); // When var result = expression.Transform("x"); // Then Assert.Equal("x", result); }
public void MatchNeither() { // Given var expression = new AltExpression( new TextExpression("x"), new TextExpression("y") ); // When var result = expression.Transform("z"); // Then Assert.Null(result); }