public void BindingIntoModelObjects() { var vm = new PropertyBindViewModel(); var view = new PropertyBindView() { ViewModel = vm }; view.OneWayBind(view.ViewModel, x => x.Model.AnotherThing, x => x.SomeTextBox.Text); Assert.Equal("Baz", view.SomeTextBox.Text); }
public void BindingToItemsControl() { var vm = new PropertyBindViewModel(); var view = new PropertyBindView() { ViewModel = vm }; view.OneWayBind(view.ViewModel, x => x.SomeCollectionOfStrings, x => x.SomeListBox.ItemsSource); Assert.True(view.SomeListBox.ItemsSource.OfType <string>().Count() > 1); }
public void ViewModelIndexerPropertyToView() { var vm = new PropertyBindViewModel(); var view = new PropertyBindView() { ViewModel = vm }; view.OneWayBind(view.ViewModel, x => x.SomeCollectionOfStrings[0].Length, x => x.SomeTextBox.Text); Assert.Equal("3", view.SomeTextBox.Text); }
public void ItemsControlShouldGetADataTemplate() { var vm = new PropertyBindViewModel(); var view = new PropertyBindView() { ViewModel = vm }; Assert.Null(view.FakeItemsControl.ItemTemplate); view.OneWayBind(vm, x => x.SomeCollectionOfStrings, x => x.FakeItemsControl.ItemsSource); Assert.NotNull(view.FakeItemsControl.ItemTemplate); }
public void BindToShouldntInitiallySetToNull() { var vm = new PropertyBindViewModel(); var view = new PropertyBindView() { ViewModel = null }; view.OneWayBind(vm, x => x.Model.AnotherThing, x => x.FakeControl.NullHatingString); Assert.Equal("", view.FakeControl.NullHatingString); view.ViewModel = vm; Assert.Equal(vm.Model.AnotherThing, view.FakeControl.NullHatingString); }
public void ItemsControlWithDisplayMemberPathSetShouldNotGetADataTemplate() { var vm = new PropertyBindViewModel(); var view = new PropertyBindView() { ViewModel = vm }; view.FakeItemsControl.DisplayMemberPath = "Bla"; Assert.Null(view.FakeItemsControl.ItemTemplate); view.OneWayBind(vm, x => x.SomeCollectionOfStrings, x => x.FakeItemsControl.ItemsSource); Assert.Null(view.FakeItemsControl.ItemTemplate); }
public void ViewModelIndexerToViewChanges() { var vm = new PropertyBindViewModel(); var view = new PropertyBindView() { ViewModel = vm }; view.OneWayBind(view.ViewModel, x => x.SomeCollectionOfStrings[0], x => x.SomeTextBox.Text); Assert.Equal("Foo", view.SomeTextBox.Text); vm.SomeCollectionOfStrings[0] = "Bar"; Assert.Equal("Bar", view.SomeTextBox.Text); }