Ejemplo n.º 1
0
        private void DecorateNodesWithParent(LessonBlockBase parent)
        {
            foreach (var c in parent.Children)
            {
                c.Parent = parent;

                if (c is LessonBlockBase)
                {
                    DecorateNodesWithParent(c as LessonBlockBase);
                }
            }
        }
        private void CanReachAllChildrenThroughInterfaces_Inner(LessonBlockBase block)
        {
            var remainingChildren = block.Children.ToList();

            var interfaces = block.GetType().GetInterfaces();

            foreach (var z in interfaces)
            {
                foreach (var prop in z.GetProperties())
                {
                    var val = prop.GetValue(block);

                    if (val is System.Collections.IEnumerable)
                    {
                        foreach (var item in (val as System.Collections.IEnumerable))
                        {
                            remainingChildren.Remove(item as LessonNode);
                        }
                    }
                    else
                    {
                        remainingChildren.Remove(val as LessonNode);
                    }
                }
            }

            // Ignore empty children (which may be placeholders)
            for (int i = 0; i < remainingChildren.Count; i++)
            {
                if (string.IsNullOrWhiteSpace(remainingChildren[i].Content.Text))
                {
                    remainingChildren.RemoveAt(i);
                    i--;
                }
            }

            if (remainingChildren.Count > 0)
            {
                Assert.Fail("Some children are not accessible through the interfaces: Count:" + remainingChildren.Count + " first:" + remainingChildren.First());
            }

            // Go deeper
            foreach (var c in block.Children)
            {
                if (c is LessonBlockBase)
                {
                    CanReachAllChildrenThroughInterfaces_Inner(c as LessonBlockBase);
                }
            }
        }
Ejemplo n.º 3
0
        private void CanParseAndRebuildEachBlock_Inner(LessonBlockBase block)
        {
            foreach (var c in block.Children)
            {
                if (c is LessonBlockBase)
                {
                    CanParseAndRebuildEachBlock_Inner(c as LessonBlockBase);
                }
            }

            var expected = block.ContentBetweenFirstAndLastSpan.Text;
            var actual   = block.BuildTextFromSpans();

            AssertEqualWithDiff(expected, actual, block);
        }
Ejemplo n.º 4
0
        private void ContentBetweenFirstAndLastSpanIsCorrectForEachBlock_Inner(LessonBlockBase block)
        {
            foreach (var c in block.Children)
            {
                if (c is LessonBlockBase)
                {
                    ContentBetweenFirstAndLastSpanIsCorrectForEachBlock_Inner(c as LessonBlockBase);
                }
            }

            var parsedContent  = block.Content;
            var contentInSpans = block.ContentBetweenFirstAndLastSpan;

            if (contentInSpans.GetIndexAfter() > parsedContent.GetIndexAfter())
            {
                Assert.Fail("ContentBetweenFirstAndLastSpan is beyond the bounds of the end of the Content");
            }
        }