Example #1
0
        public void CreateWindowSetsUpTitleBindingIfViewModelIsIHaveDisplayName()
        {
            var model = new Screen();
            var window = new Window();
            this.viewManager.Setup(x => x.CreateAndBindViewForModelIfNecessary(model)).Returns(window);
            
            this.windowManager.CreateWindow(model, false);

            var e = window.GetBindingExpression(Window.TitleProperty);
            Assert.NotNull(e);
            Assert.AreEqual(BindingMode.TwoWay, e.ParentBinding.Mode);
            Assert.AreEqual("DisplayName", e.ParentBinding.Path.Path);
        }
Example #2
0
        public void CreateWindowDoesNotSetUpTitleBindingIfTitleHasABindingAlready()
        {
            var model = new Screen();
            var window = new Window();
            var binding = new Binding("Test") { Mode = BindingMode.TwoWay };
            window.SetBinding(Window.TitleProperty, binding);
            this.viewManager.Setup(x => x.CreateAndBindViewForModelIfNecessary(model)).Returns(window);

            this.windowManager.CreateWindow(model, false);

            var e = window.GetBindingExpression(Window.TitleProperty);
            Assert.AreEqual("Test", e.ParentBinding.Path.Path);
        }
Example #3
0
        public void CreateWindowDoesSetUpTitleBindingIfTitleIsNameOfTheClass()
        {
            var model = new Screen();
            var window = new Window();
            window.Title = "Window";
            this.viewManager.Setup(x => x.CreateAndBindViewForModelIfNecessary(model)).Returns(window);

            this.windowManager.CreateWindow(model, false);

            var e = window.GetBindingExpression(Window.TitleProperty);
            Assert.AreEqual("DisplayName", e.ParentBinding.Path.Path);
        }
Example #4
0
        public void CreateWindowDoesNotSetUpTitleBindingIfTitleHasAValueAlready()
        {
            var model = new Screen();
            var window = new Window();
            window.Title = "Foo";
            this.viewManager.Setup(x => x.CreateAndBindViewForModelIfNecessary(model)).Returns(window);

            this.windowManager.CreateWindow(model, false);

            var e = window.GetBindingExpression(Window.TitleProperty);
            Assert.IsNull(e);
            Assert.AreEqual("Foo", window.Title);
        }