예제 #1
0
        public void BindToNullShouldThrowHelpfulError()
        {
            var view = new PropertyBindView()
            {
                ViewModel = null
            };

            Assert.Throws <ArgumentNullException>(() =>
                                                  view.WhenAnyValue(x => x.FakeControl.NullHatingString)
                                                  .BindTo(view.ViewModel, x => x.Property1));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }