public void OneWayPropertyBindingDefaultValueValueType_SetSource_DestinationUpdated() { ///Arrange var view = new DummyOneWayPropertyView(); var viewModel = new DummyOneWayPropertyViewModel(); view.BindingContext = new BindingContext(); view.BindingContext.Add(view.Bind(v => v.ViewPropertyInt, vm => ((DummyOneWayPropertyViewModel)vm).ViewModelPropertyInt, null, 1234)); view.ViewModel = viewModel; ///Act ///Assert Assert.AreEqual(1234, view.ViewPropertyInt); }
public void Bind_NewMVVM_PropertyBindedFromVMtoView() { ///Arrange var view = new DummyOneWayPropertyView(); var viewModel = new DummyOneWayPropertyViewModel(); view.BindingContext = new BindingContext(); view.BindingContext.Add(view.Bind(v => v.ViewProperty, vm => ((DummyOneWayPropertyViewModel)vm).ViewModelProperty)); view.ViewModel = viewModel; ///Act viewModel.ViewModelProperty = "Changed!"; ///Assert Assert.AreEqual("Changed!", view.ViewProperty); }
public void PropertyBindingWithFormatterCallbak_SetSource_DestinationUpdatedWithFormat() { ///Arrange var view = new DummyOneWayPropertyView(); var viewModel = new DummyOneWayPropertyViewModel(); view.BindingContext = new BindingContext(); view.BindingContext.Add(view.Bind(v => v.ViewProperty, vm => ((DummyOneWayPropertyViewModel)vm).ViewModelPropertyInt, new VASInt32Converter(), null, i => i + "FORMATTED!")); view.ViewModel = viewModel; ///Act viewModel.ViewModelPropertyInt = 12; ///Assert Assert.AreEqual("12FORMATTED!", view.ViewProperty); }
public void OneWayPropertyBindingWithConverterFrom_SetSource_DestinationUpdated() { ///Arrange var view = new DummyOneWayPropertyView(); var viewModel = new DummyOneWayPropertyViewModel(); view.BindingContext = new BindingContext(); view.BindingContext.Add(view.Bind(v => v.ViewProperty, vm => ((DummyOneWayPropertyViewModel)vm).ViewModelPropertyInt, new VASInt32Converter())); view.ViewModel = viewModel; ///Act viewModel.ViewModelPropertyInt = 12; ///Assert Assert.AreEqual("12", view.ViewProperty); }
public void OneWayPropertyBindingDefaultValueReferenceType_SetSource_DestinationUpdated() { ///Arrange var view = new DummyOneWayPropertyView(); var viewModel = new DummyOneWayPropertyViewModel(); view.BindingContext = new BindingContext(); view.BindingContext.Add(view.Bind(v => v.ViewComplexProperty, vm => ((DummyOneWayPropertyViewModel)vm).ViewModelComplexProperty, null, new ConfigDummy() { Lang = "MyLang" })); view.ViewModel = viewModel; ///Act ///Assert Assert.AreEqual("MyLang", view.ViewComplexProperty.Lang); }