Пример #1
0
        /// <summary>
        /// Regenerates the <see cref="RenderTree"/> and adds the changes to the
        /// <paramref name="batchBuilder"/>.
        /// </summary>
        public void Render(RenderBatchBuilder batchBuilder)
        {
            // Swap the old and new tree builders
            (_renderTreeBuilderCurrent, _renderTreeBuilderPrevious) = (_renderTreeBuilderPrevious, _renderTreeBuilderCurrent);

            _renderTreeBuilderCurrent.Clear();
            _component.BuildRenderTree(_renderTreeBuilderCurrent);
            _diffComputer.ApplyNewRenderTreeVersion(
                batchBuilder,
                _componentId,
                _renderTreeBuilderPrevious.GetFrames(),
                _renderTreeBuilderCurrent.GetFrames());
        }
        public void ThrowsIfAssigningUnknownPropertiesToChildComponents()
        {
            // Arrange
            var testObject = new object();

            newTree.OpenComponent <FakeComponent>(0);
            newTree.AddAttribute(1, "SomeUnknownProperty", 123);
            newTree.CloseComponent();

            // Act/Assert
            var ex = Assert.Throws <InvalidOperationException>(() =>
            {
                diff.ApplyNewRenderTreeVersion(new RenderBatchBuilder(), 0, oldTree.GetFrames(), newTree.GetFrames());
            });

            Assert.Equal($"Component of type '{typeof(FakeComponent).FullName}' does not have a property matching the name 'SomeUnknownProperty'.", ex.Message);
        }