public void InstantiatesChildComponentsForInsertedFrames()
        {
            // Arrange
            oldTree.AddText(10, "text1");                       //  0: text1
            oldTree.OpenElement(11, "container");               //  1: <container>
            oldTree.CloseElement();                             //     </container>
            newTree.AddText(10, "text1");                       //  0: text1
            newTree.OpenElement(11, "container");               //  1: <container>
            newTree.OpenComponent <FakeComponent>(12);          //  2:   <FakeComponent>
            newTree.CloseComponent();                           //       </FakeComponent>
            newTree.OpenComponent <FakeComponent2>(13);         //  3:   <FakeComponent2>
            newTree.CloseComponent();                           //       </FakeComponent2>
            newTree.CloseElement();                             //     </container>

            // Act
            var renderBatch = GetRenderedBatch();

            // Assert
            Assert.Equal(3, renderBatch.UpdatedComponents.Count);

            // First component is the root one
            var firstComponentDiff = renderBatch.UpdatedComponents.Array[0];

            Assert.Collection(firstComponentDiff.Edits,
                              entry => AssertEdit(entry, RenderTreeEditType.StepIn, 1),
                              entry =>
            {
                AssertEdit(entry, RenderTreeEditType.PrependFrame, 0);
                Assert.Equal(0, entry.ReferenceFrameIndex);
            },
                              entry =>
            {
                AssertEdit(entry, RenderTreeEditType.PrependFrame, 1);
                Assert.Equal(1, entry.ReferenceFrameIndex);
            },
                              entry => AssertEdit(entry, RenderTreeEditType.StepOut, 0));
            Assert.Collection(firstComponentDiff.ReferenceFrames,
                              frame => AssertFrame.ComponentWithInstance <FakeComponent>(frame, 0, 12),
                              frame => AssertFrame.ComponentWithInstance <FakeComponent2>(frame, 1, 13));

            // Second in batch is the first child component
            var secondComponentDiff = renderBatch.UpdatedComponents.Array[1];

            Assert.Equal(0, secondComponentDiff.ComponentId);
            Assert.Empty(secondComponentDiff.Edits);           // Because FakeComponent produces no frames
            Assert.Empty(secondComponentDiff.ReferenceFrames); // Because FakeComponent produces no frames

            // Third in batch is the second child component
            var thirdComponentDiff = renderBatch.UpdatedComponents.Array[2];

            Assert.Equal(1, thirdComponentDiff.ComponentId);
            Assert.Collection(thirdComponentDiff.Edits,
                              entry => AssertEdit(entry, RenderTreeEditType.PrependFrame, 0));
            Assert.Collection(thirdComponentDiff.ReferenceFrames,
                              frame => AssertFrame.Text(frame, $"Hello from {nameof(FakeComponent2)}"));
        }
        public void InstantiatesChildComponentsForInsertedFrames()
        {
            // Arrange
            oldTree.AddContent(10, "text1");                    //  0: text1
            oldTree.OpenElement(11, "container");               //  1: <container>
            oldTree.CloseElement();                             //     </container>
            newTree.AddContent(10, "text1");                    //  0: text1
            newTree.OpenElement(11, "container");               //  1: <container>
            newTree.OpenComponent <FakeComponent>(12);          //  2:   <FakeComponent>
            newTree.CloseComponent();                           //       </FakeComponent>
            newTree.OpenComponent <FakeComponent2>(13);         //  3:   <FakeComponent2>
            newTree.CloseComponent();                           //       </FakeComponent2>
            newTree.CloseElement();                             //     </container>

            // Act
            var renderBatch = GetRenderedBatch();

            // Assert
            var diff = renderBatch.UpdatedComponents.Single();

            Assert.Collection(diff.Edits,
                              entry => AssertEdit(entry, RenderTreeEditType.StepIn, 1),
                              entry =>
            {
                AssertEdit(entry, RenderTreeEditType.PrependFrame, 0);
                Assert.Equal(0, entry.ReferenceFrameIndex);
            },
                              entry =>
            {
                AssertEdit(entry, RenderTreeEditType.PrependFrame, 1);
                Assert.Equal(1, entry.ReferenceFrameIndex);
            },
                              entry => AssertEdit(entry, RenderTreeEditType.StepOut, 0));
            AssertFrame.ComponentWithInstance <FakeComponent>(renderBatch.ReferenceFrames.Array[0], 0, null, 12);
            AssertFrame.ComponentWithInstance <FakeComponent2>(renderBatch.ReferenceFrames.Array[1], 1, null, 13);
        }