public void TermNode_WhenToStringCalled_ReturnsCorrectString() { // Arranged: var factNodeMock1 = new Mock <IFactorNode>(); factNodeMock1.Setup(node => node.ToString()).Returns(() => "<T>"); var factNodeMock2 = new Mock <IFactorNode>(); factNodeMock2.Setup(node => node.ToString()).Returns(() => "<U>"); var termNode = new TermNode(new Token(TokenKind.String, "\"a\""), _tracer); termNode.AppendFactor(factNodeMock1.Object); termNode.AppendFactor(factNodeMock2.Object); // Act: var actual = termNode.ToString(); // Assert: Assert.That(actual, Is.EqualTo("<T> <U>")); }
public ITermNode BuildTree() { var termNode = new TermNode(new Token(), _tracer) { PreActionNode = string.IsNullOrEmpty(PreActionName) ? null : new ActionNode(new Token(TokenKind.Action, PreActionName), _tracer), PostActionNode = string.IsNullOrEmpty(PostActionName) ? null : new ActionNode(new Token(TokenKind.Action, PostActionName), _tracer) }; foreach (var fact in _factors) { var factorNode = fact.BuildTree(); termNode.AppendFactor(factorNode); } return(termNode); }