Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        public void TestUpdateProperty_WithoutConverter()
        {
            var viewModel = new DummyPropertyViewModel();
            var binding   = new DummyPropertyBinding <string, string> (vm => ((DummyPropertyViewModel)vm).Prop1);

            binding.ViewModel = viewModel;
            viewModel.Prop1   = "foo";

            Assert.AreEqual("foo", binding.val);
        }
Beispiel #4
0
        public void TestUpdateProperty_WithConverter()
        {
            var viewModel = new DummyPropertyViewModel();
            var binding   = new DummyPropertyBinding <int, string> (vm => ((DummyPropertyViewModel)vm).Prop2, new Int32Converter());

            binding.ViewModel = viewModel;
            viewModel.Prop2   = 32;

            Assert.AreEqual("32", binding.val);
        }
Beispiel #5
0
        public void TestBind_WithPrivateSetter_WithoutConverter()
        {
            DummyPropertyBinding <string, string> binding = null;
            var viewModel = new DummyPropertyViewModel();

            Assert.DoesNotThrow(() => { binding = new DummyPropertyBinding <string, string> (vm => ((DummyPropertyViewModel)vm).Prop3); });

            binding.ViewModel = viewModel;
            binding.ViewChanged("Foo");
            Assert.AreEqual("Dog", viewModel.Prop3);
        }
Beispiel #6
0
        public void Dispose_NullViewModel_NoException()
        {
            DummyPropertyBinding <int, string> binding = null;
            var viewModel = new DummyPropertyViewModel();

            binding = new DummyPropertyBinding <int, string> (vm => ((DummyPropertyViewModel)vm).Prop4, new Int32Converter());

            binding.ViewModel = viewModel;

            binding.ViewModel = null;
            Assert.DoesNotThrow(binding.Dispose);
        }
Beispiel #7
0
        public void TestBindAnidatedProperties_WithConverter()
        {
            var parent = new DummyPropertyViewModel();
            var child  = new DummyPropertyViewModel();

            parent.Prop5 = child;

            var binding = new DummyPropertyBinding <int, string> (vm => ((DummyPropertyViewModel)vm).Prop5.Prop2, new Int32Converter());

            binding.ViewModel = parent;
            child.Prop2       = 32;
            Assert.AreEqual("32", binding.val);
        }
Beispiel #8
0
        public void TestBindAnidatedProperties_WithoutConverter()
        {
            var parent = new DummyPropertyViewModel();
            var child  = new DummyPropertyViewModel();

            parent.Prop5 = child;

            var binding = new DummyPropertyBinding <string, string> (vm => ((DummyPropertyViewModel)vm).Prop5.Prop1);

            binding.ViewModel = parent;
            child.Prop1       = "foo";
            Assert.AreEqual("foo", binding.val);
        }
Beispiel #9
0
        public void TestBind_WithPrivateSetter_WithConverter()
        {
            DummyPropertyBinding <int, string> binding = null;
            var viewModel = new DummyPropertyViewModel();

            Assert.DoesNotThrow(() => {
                binding =
                    new DummyPropertyBinding <int, string> (vm => ((DummyPropertyViewModel)vm).Prop4, new Int32Converter());
            });

            binding.ViewModel = viewModel;
            binding.ViewChanged("32");
            Assert.AreEqual(3, viewModel.Prop4);
        }
Beispiel #10
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);
        }
Beispiel #11
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);
        }