public void Setter_With_TwoWay_Binding_Should_Update_Source() { using (UnitTestApplication.Start(TestServices.MockThreadingInterface)) { var data = new Data { Foo = "foo", }; var control = new TextBox { DataContext = data, }; var setter = new Setter { Property = TextBox.TextProperty, Value = new Binding { Path = "Foo", Mode = BindingMode.TwoWay } }; setter.Apply(null, control, null); Assert.Equal("foo", control.Text); control.Text = "bar"; Assert.Equal("bar", data.Foo); } }
public void Setter_With_TwoWay_Binding_Should_Update_Source() { using (PerspexLocator.EnterScope()) { PerspexLocator.CurrentMutable .Bind<IPlatformThreadingInterface>() .ToConstant(Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)); var data = new Data { Foo = "foo", }; var control = new TextBox { DataContext = data, }; var setter = new Setter { Property = TextBox.TextProperty, Value = new Binding { Path = "Foo", Mode = BindingMode.TwoWay } }; setter.Apply(null, control, null); Assert.Equal("foo", control.Text); control.Text = "bar"; Assert.Equal("bar", data.Foo); } }