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); }
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); }
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); }
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; }
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); }