Exemplo n.º 1
0
        public void GetDescendantsShouldReturnAllDescendants()
        {
            // Arrange
            // a+bc*
            var charNodeA      = new CharacterNode('a');
            var charNodeB      = new CharacterNode('b');
            var charNodeC      = new CharacterNode('c');
            var quantifierPlus = new QuantifierPlusNode(charNodeA);
            var quantifierStar = new QuantifierStarNode(charNodeC);
            var grandchildren  = new List <RegexNode> {
                quantifierPlus, charNodeB, quantifierStar
            };
            var concatenationNode = new ConcatenationNode(grandchildren);
            var target            = new TestRegexNode(concatenationNode);

            // Act
            IEnumerable <RegexNode> result = target.GetDescendantNodes();

            // Assert
            result.Count().ShouldBe(6);
            result.First().ShouldBe(charNodeA);
            result.ElementAt(1).ShouldBe(quantifierPlus);
            result.ElementAt(2).ShouldBe(charNodeB);
            result.ElementAt(3).ShouldBe(charNodeC);
            result.ElementAt(4).ShouldBe(quantifierStar);
            result.Last().ShouldBe(concatenationNode);
        }
Exemplo n.º 2
0
        public void GetDescendantsOnNodeWithNoChildrenShouldReturnEmptyIEnumerable()
        {
            // Arrange
            var target = new TestRegexNode();

            // Act
            IEnumerable <RegexNode> result = target.GetDescendantNodes();

            // Assert
            result.ShouldBeEmpty();
        }