public void TestSimpleDependency()
        {
            var container = new Types.DependentPropertyContainer {
                Title = "Title", Instance = new Types.SimpleObject {
                    Name = "Test"
                }
            };
            var testContext     = new TestContainerContext();
            var instanceContext = testContext.CreateInstanceContext(container);

            testContext.GraphViewModelService.AvailableUpdaters.Add(new SimpleDependentPropertiesUpdater());
            var viewModel = instanceContext.CreateViewModel();
            var titleNode = viewModel.RootNode.GetChild(Title);
            var nameNode  = viewModel.RootNode.GetChild(Instance).GetChild(Name);

            Assert.True(titleNode.AssociatedData.ContainsKey(TestDataKey));
            Assert.Equal("Test", titleNode.AssociatedData[TestDataKey]);
            Assert.Equal(0, titleNode.AssociatedData[UpdateCountKey]);

            nameNode.NodeValue = "NewValue";
            Assert.True(titleNode.AssociatedData.ContainsKey(TestDataKey));
            Assert.Equal("NewValue", titleNode.AssociatedData[TestDataKey]);
            Assert.Equal(1, titleNode.AssociatedData[UpdateCountKey]);

            nameNode.NodeValue = "NewValue2";
            Assert.True(titleNode.AssociatedData.ContainsKey(TestDataKey));
            Assert.Equal("NewValue2", titleNode.AssociatedData[TestDataKey]);
            Assert.Equal(2, titleNode.AssociatedData[UpdateCountKey]);
        }
Esempio n. 2
0
        private static TestInstanceContext BuildContext(object instance)
        {
            var context = new TestContainerContext();

            return(context.CreateInstanceContext(instance));
        }