示例#1
0
        public void BindIntStringTest()
        {
            UserViewModel uvm = new UserViewModel()
            {
                name   = "aaa",
                age    = 18,
                height = 1.82f
            };

            UserView uv = new UserView();

            SystemConvertProvider <int, string> bind = new SystemConvertProvider <int, string>();

            bind.Bind(uvm, "age", uv, "ageInput", BindType.TwoWay);
            bind.SyncTarget();
            Assert.AreEqual(uv.ageInput, uvm.age.ToString());
            uv.ageInput = "20";
            bind.SyncSource();
            Assert.AreEqual(uvm.age, 20);
        }
示例#2
0
        public void BindIntFloatTest()
        {
            UserViewModel uvm = new UserViewModel()
            {
                name   = "aaa",
                age    = 18,
                height = 1.82f
            };

            UserView uv = new UserView();

            SystemConvertProvider <int, float> bind = new SystemConvertProvider <int, float>();

            bind.Bind(uvm, "age", uv, "percent", BindType.TwoWay);
            uvm.age = 10;
            bind.SyncTarget();
            Assert.AreEqual(uv.percent, 10);
            uv.percent = 20;
            bind.SyncSource();
            Assert.AreEqual(uvm.age, 20);
        }