Exemplo n.º 1
0
        public void   双向绑定()
        {
            TestView    view    = new TestView();
            BindFactory factory = new BindFactory(view);
            ObservableProperty <string> property = Substitute.For <ObservableProperty <string> >("1");

            factory.TwoWayBind <TestView, string, int>(view, property, (i) => i.ToString(), int.Parse);
            Assert.IsTrue(view.Age == 1);
            property.Value = "2";
            Assert.IsTrue(view.Age == 2);
            ((IComponentEvent <int>)view).GetComponentEvent().Invoke(3);
            Assert.IsTrue(property.Value == "3");
        }
Exemplo n.º 2
0
        public void 双向绑定()
        {
            TestView    view    = new TestView();
            BindFactory factory = new BindFactory(view);
            ObservableProperty <int> property = Substitute.For <ObservableProperty <int> >(1);

            factory.TwoWayBind(view, property);
            Assert.IsTrue(view.Age == 1);
            property.Value = 2;
            Assert.IsTrue(view.Age == 2);
            ((IComponentEvent <int>)view).GetComponentEvent().Invoke(3);
            Assert.IsTrue(property.Value == 3);
        }