Esempio n. 1
0
        public void EmpyContainerNode_QueryDescendantNodes_ReturnsNullOrEmpty(Fb2Container node)
        {
            var firstAllowedChildName = node.AllowedElements.First();
            Func <Fb2Node, bool> firstAllowedChildPredicate = nodeToCompare => nodeToCompare.Name.Equals(firstAllowedChildName);

            node.GetDescendants(firstAllowedChildName).Should().BeEmpty();
            node.GetDescendants(firstAllowedChildPredicate).Should().BeEmpty();
            node.GetDescendants <Fb2Node>().Should().BeEmpty();
            node.GetDescendants <BodySection>().Should().BeEmpty();

            node.GetFirstDescendant(firstAllowedChildName).Should().BeNull();
            node.GetFirstDescendant(firstAllowedChildPredicate).Should().BeNull();
            node.GetFirstDescendant <Fb2Node>().Should().BeNull();
            node.GetFirstDescendant <BodySection>().Should().BeNull();

            var success = node.TryGetFirstDescendant(firstAllowedChildName, out var resultNode);

            success.Should().BeFalse();
            resultNode.Should().BeNull();

            var predicateSuccess = node.TryGetFirstDescendant(firstAllowedChildPredicate, out var resultPredicateNode);

            predicateSuccess.Should().BeFalse();
            resultPredicateNode.Should().BeNull();

            var genericSuccess = node.TryGetFirstDescendant <Fb2Node>(out var resultGenericNode);

            genericSuccess.Should().BeFalse();
            resultGenericNode.Should().BeNull();

            var bookBodySuccess = node.TryGetFirstDescendant <BookBody>(out var resultBookBody);

            bookBodySuccess.Should().BeFalse();
            resultBookBody.Should().BeNull();
        }