示例#1
0
        public void When_Native()
        {
            var SUT    = new MyNativeObject();
            var source = new MyObject();

            SUT.SetBinding(
                MyNativeObject.MyValueProperty,
                new Binding
            {
                Path   = new PropertyPath("Value"),
                Source = source,
                Mode   = BindingMode.OneWay
            }
                );

            Assert.AreEqual(0, SUT.MyValue);

            source.Value = 22;
            Assert.AreEqual(22, SUT.MyValue);
        }
示例#2
0
        public void When_Native_And_Collected()
        {
            var SUT    = new MyNativeObject();
            var source = new MyObject();

            SUT.SetBinding(
                MyNativeObject.MyValueProperty,
                new Binding
            {
                Path   = new PropertyPath("Value"),
                Source = source,
                Mode   = BindingMode.OneWay
            }
                );

            Assert.AreEqual(0, SUT.MyValue);

            source.Value = 22;
            Assert.AreEqual(22, SUT.MyValue);

            SUT.Dispose();
            source.Value = 99;
            Assert.AreEqual(22, SUT.MyValue);             //Binding shouldn't be updated after target is natively collected
        }