public void Container_CanContainText_AddMultipleTextContent_Works(Fb2Container node) { node.Should().NotBeNull(); if (!node.CanContainText) { return; } node.AddTextContent("test text"); node.Content.Count.Should().Be(1); var first = node.GetFirstChild <TextItem>(); first.Should().NotBeNull(); first.Content.Should().Be("test text"); node.AddTextContent("test text 2", " "); node.Content.Count.Should().Be(1); var second = node.GetFirstChild <TextItem>(); second.Should().NotBeNull(); second.Content.Should().Be("test text test text 2"); first.Content.Should().Be("test text test text 2"); node.AddTextContent("test text 3", " "); node.Content.Count.Should().Be(1); second.Content.Should().Be("test text test text 2 test text 3"); first.Content.Should().Be("test text test text 2 test text 3"); }
public void Container_CanContainText_AddMultipleTextNodes_WithContainers_Works(Fb2Container node) { node.Should().NotBeNull(); if (!node.CanContainText) { return; } node.AddContent(new TextItem().AddContent("test text")); node.Content.Count.Should().Be(1); node.Parent.Should().BeNull(); var first = node.GetFirstChild <TextItem>() !; first.Should().NotBeNull(); first.Content.Should().Be("test text"); first.Parent.Should().NotBeNull().And.Be(node); node.AddContent(new TextItem().AddContent(" test text 2 ")); node.Content.Count.Should().Be(1); var second = node.GetFirstChild <TextItem>() !; second.Should().NotBeNull(); second.Content.Should().Be("test text test text 2 "); //second.Parent.Should().NotBeNull(); first.Content.Should().Be("test text test text 2 "); node.AddContent(node.AllowedElements.First()); var firstAllowedElement = node.GetFirstChild(node.AllowedElements.First()) !; firstAllowedElement.Should().NotBeNull(); firstAllowedElement.Parent.Should().NotBeNull().And.Be(node); node.Content.Count.Should().Be(2); node.AddContent(new TextItem().AddContent("test text 3 ")); node.Content.Count.Should().Be(3); var textItems = node.GetChildren <TextItem>().ToList(); textItems.Count.Should().Be(2); textItems.First().Content.Should().Be("test text test text 2 "); textItems.Last().Parent.Should().NotBeNull().And.Be(node); textItems.Last().Content.Should().Be("test text 3 "); }
public void EmpyContainerNode_QueryChildrenNodes_ReturnsNullOrEmpty(Fb2Container node) { var firstAllowedChildName = node.AllowedElements.First(); bool firstAllowedChildPredicate(Fb2Node nodeToCompare) => nodeToCompare.Name.Equals(firstAllowedChildName); node.GetChildren(firstAllowedChildName).Should().BeEmpty(); node.GetChildren(firstAllowedChildPredicate).Should().BeEmpty(); node.GetChildren <Fb2Node>().Should().BeEmpty(); node.GetChildren <BodySection>().Should().BeEmpty(); node.GetFirstChild(firstAllowedChildName).Should().BeNull(); node.GetFirstChild(firstAllowedChildPredicate).Should().BeNull(); node.GetFirstChild((string)null).Should().BeNull(); node.GetFirstChild("").Should().BeNull(); node.GetFirstChild <Fb2Node>().Should().BeNull(); node.GetFirstChild <BodySection>().Should().BeNull(); }