Example #1
0
        public void TestUpdateView_WithConverter()
        {
            var viewModel = new DummyPropertyViewModel();
            var binding   = new DummyPropertyBinding <int, string> (vm => ((DummyPropertyViewModel)vm).Prop2, new Int32Converter());

            binding.ViewModel = viewModel;
            binding.ViewChanged("32");
            Assert.AreEqual(32, viewModel.Prop2);
        }
Example #2
0
        public void TestUpdateView_WithoutConverter()
        {
            var viewModel = new DummyPropertyViewModel();
            var binding   = new DummyPropertyBinding <string, string> (vm => ((DummyPropertyViewModel)vm).Prop1);

            binding.ViewModel = viewModel;
            binding.ViewChanged("Foo");
            Assert.AreEqual("Foo", viewModel.Prop1);
        }
Example #3
0
        public void TestChangeViewModel_WithConverter()
        {
            var viewModel1 = new DummyPropertyViewModel();
            var viewModel2 = new DummyPropertyViewModel();
            var binding    = new DummyPropertyBinding <int, string> (vm => ((DummyPropertyViewModel)vm).Prop2, new Int32Converter());

            binding.ViewModel = viewModel1;
            binding.ViewModel = viewModel2;

            binding.ViewChanged("32");

            Assert.IsNull(viewModel1.Prop1);
            Assert.AreEqual(32, viewModel2.Prop2);
        }
Example #4
0
        public void TestChangeViewModel_WithoutConverter()
        {
            var viewModel1 = new DummyPropertyViewModel();
            var viewModel2 = new DummyPropertyViewModel();
            var binding    = new DummyPropertyBinding <string, string> (vm => ((DummyPropertyViewModel)vm).Prop1);

            binding.ViewModel = viewModel1;
            binding.ViewModel = viewModel2;

            binding.ViewChanged("bar");

            Assert.IsNull(viewModel1.Prop1);
            Assert.AreEqual("bar", viewModel2.Prop1);
        }