public void BindToNullShouldThrowHelpfulError() { var view = new PropertyBindView() { ViewModel = null }; Assert.Throws <ArgumentNullException>(() => view.WhenAnyValue(x => x.FakeControl.NullHatingString) .BindTo(view.ViewModel, x => x.Property1)); }
public void BindToTypeConversionSmokeTest() { var vm = new PropertyBindViewModel(); var view = new PropertyBindView() { ViewModel = null }; view.WhenAnyValue(x => x.ViewModel.JustADouble) .BindTo(view, x => x.FakeControl.NullHatingString); Assert.Equal("", view.FakeControl.NullHatingString); view.ViewModel = vm; Assert.Equal(vm.JustADouble.ToString(), view.FakeControl.NullHatingString); }
public void ItemsControlShouldGetADataTemplateInBindTo() { var vm = new PropertyBindViewModel(); var view = new PropertyBindView() { ViewModel = vm }; Assert.Null(view.FakeItemsControl.ItemTemplate); vm.WhenAnyValue(x => x.SomeCollectionOfStrings) .BindTo(view, v => v.FakeItemsControl.ItemsSource); Assert.NotNull(view.FakeItemsControl.ItemTemplate); view.WhenAnyValue(x => x.FakeItemsControl.SelectedItem) .BindTo(vm, x => x.Property1); }