コード例 #1
0
        public void BiconnectViewTargetNotRx()
        {
            var view = new TestViewObject();
            var model = new TestViewModel();
            view.Model = model;

            view.Bind(x => x.StringProperty).Mate(view.nonRxTestLabel);

            Assert.IsNull(model.StringProperty);
            view.nonRxTestLabel.Text = "foo";
            Assert.AreEqual("foo", model.StringProperty);
        }
コード例 #2
0
        public void Bind()
        {
            var view = new TestViewObject();
            var model = new TestViewModel();
            view.Model = model;

            view.Bind(x => x.StringProperty).To(view.testLabel, x => x.Text);

            Assert.IsNull(view.testLabel.Text);
            model.StringProperty = "foo";
            Assert.AreEqual("foo", view.testLabel.Text);
        }
コード例 #3
0
        public void ConnectSubInitiallyNull()
        {
            var view = new TestViewObject();
            var model = new TestViewModel();
            view.Model = model;

            view.Bind(x => x.StringProperty).To(view, x => x.subViewObject.testLabel.Text);

            var subObject = new TestSubViewObject();
            Assert.IsNull(subObject.testLabel.Text);
            model.StringProperty = "foo";
            Assert.IsNull(subObject.testLabel.Text);

            view.subViewObject = subObject;
            model.StringProperty = "foo2";
            Assert.AreEqual("foo2", subObject.testLabel.Text);
        }
コード例 #4
0
        public async void ConnectRunsOnUiScheduler()
        {
            var originalThread = Thread.CurrentThread;
            var originalScheduler = RxApp.UiScheduler;
            var completionSource = new TaskCompletionSource<Unit>();
            RxApp.UiScheduler = NewThreadScheduler.Default;

            var view = new TestViewObject();
            var model = new TestViewModel();
            view.Model = model;

            view.testLabel.TextSetHandler = () =>
            {
                var thread = Thread.CurrentThread;
                Assert.AreNotEqual(originalThread, thread);
                completionSource.SetResult(default(Unit));
            };
            view.Bind(x => x.StringProperty).To(view.testLabel, x => x.Text);

            await completionSource.Task;

            RxApp.UiScheduler = originalScheduler;
        }
コード例 #5
0
        public void UpdateModelAfterBind()
        {
            var viewObject = new TestViewObject();
            var model = new TestViewModel();
            model.StringProperty = "foo";
            viewObject.Model = model;
            string s = null;
            viewObject.Bind(x => x.StringProperty).ObserveModelProperty().Subscribe(x =>
            {
                s = x;
            });
            Assert.AreEqual("foo", s);

            model.StringProperty = "bar";
            Assert.AreEqual("bar", s);
        }