public void DataContainerBase_CanAccessChildDataFromRoot()
        {
            DataContainerBase Root = (DataContainerBase)DataContainerBuilder.Create("Root")
                                     .DataContainer("Child", b => b
                                                    .DataContainer("GrandChild", c => c
                                                                   .Data("A", 1)
                                                                   .Data("B", 2)))
                                     .Build();

            int a = Root.GetValue(new Key <int>("Child.GrandChild.A"));
            int b = Root.GetValue(new Key <int>("Child.GrandChild.B"));

            Assert.Equal(1, a);
            Assert.Equal(2, b);
        }
        public void DataContainerBase_SetBinding_MustBindOneWayToSource()
        {
            const string PROP_NAME = "IntProperty";
            const int    VALUE     = 42;
            const int    NEW_VALUE = 14;

            DataContainerBase property = (DataContainerBase)PropertyContainerBuilder.Create()
                                         .Property(PROP_NAME, VALUE)
                                         .Build();

            var bindingTarget = new BindingTestObject();

            Assert.NotEqual(VALUE, bindingTarget.IntProperty);

            property.SetBinding(PROP_NAME, () => bindingTarget.IntProperty, BindingMode.OneWayToSource);

            Assert.Equal(VALUE, bindingTarget.IntProperty);

            property.SetValue(PROP_NAME, NEW_VALUE);

            Assert.NotEqual(NEW_VALUE, bindingTarget.IntProperty);
            Assert.Equal(VALUE, bindingTarget.IntProperty);

            bindingTarget.IntProperty = 32;

            int propertyValue = 0;

            property.GetValue(PROP_NAME, ref propertyValue);

            property.RemoveBinding(PROP_NAME, () => bindingTarget.IntProperty);

            Assert.Equal(propertyValue, bindingTarget.IntProperty);
        }
        public void DataContainerBase_Get_MustGetCorrectValue()
        {
            const string PROP_NAME = "IntProperty";

            DataContainerBase property = (DataContainerBase)PropertyContainerBuilder.Create()
                                         .Property(PROP_NAME, 42)
                                         .Build();

            int  prop             = 0;
            bool containsProperty = property.GetValue(PROP_NAME, ref prop);

            Assert.True(containsProperty);
            Assert.NotEqual(0, prop);
            Assert.Equal(42, prop);

            int prop2 = property.GetValue <int>(PROP_NAME);

            Assert.NotEqual(0, prop2);
            Assert.Equal(42, prop2);
        }
        public void DataContainerBase_Get_MustReturnDefaultIfNotPresent()
        {
            const string PROP_NAME = "IntProperty";

            DataContainerBase property = (DataContainerBase)PropertyContainerBuilder.Create()
                                         .Property(PROP_NAME, 42)
                                         .Build();

            int  prop             = 0;
            bool containsProperty = property.GetValue("blah", ref prop);

            Assert.False(containsProperty);
            Assert.Equal(default, prop);