コード例 #1
0
        public void ViewHelperShouldWrapDocumentOwnerIfDependencyObject_Test_T122209()
        {
            var            button          = new Button();
            var            viewModel       = new ViewModel();
            var            parentViewModel = new ViewModel();
            IDocumentOwner owner           = new TestDocumentOwner();

            button.DataContext = viewModel;
            ViewHelper.InitializeView(button, null, "test", parentViewModel, owner);
            Assert.AreEqual(owner, viewModel.DocumentOwner);
            Assert.AreEqual(owner, ViewModelExtensions.GetDocumentOwner(button));

            button             = new Button();
            button.DataContext = viewModel;
            owner = new TestServiceDocumentOwner();
            ViewHelper.InitializeView(button, null, "test", parentViewModel, owner);
            ViewHelper.DocumentOwnerWrapper ownerWrapper = viewModel.DocumentOwner as ViewHelper.DocumentOwnerWrapper;
            Assert.IsNotNull(ownerWrapper);
            Assert.IsTrue(ownerWrapper.Equals(owner));
            Assert.AreEqual(owner, ownerWrapper.ActualOwner);
            Assert.AreEqual(ownerWrapper, ViewModelExtensions.GetDocumentOwner(button));
        }
コード例 #2
0
        public void ViewHelperShouldWrapDocumentOwnerIfDependencyObject_Test_T122209() {
            var button = new Button();
            var viewModel = new ViewModel();
            var parentViewModel = new ViewModel();
            IDocumentOwner owner = new TestDocumentOwner();
            button.DataContext = viewModel;
            ViewHelper.InitializeView(button, null, "test", parentViewModel, owner);
            Assert.AreEqual(owner, viewModel.DocumentOwner);
            Assert.AreEqual(owner, ViewModelExtensions.GetDocumentOwner(button));

            button = new Button();
            button.DataContext = viewModel;
            owner = new TestServiceDocumentOwner();
            ViewHelper.InitializeView(button, null, "test", parentViewModel, owner);
            ViewHelper.DocumentOwnerWrapper ownerWrapper = viewModel.DocumentOwner as ViewHelper.DocumentOwnerWrapper;
            Assert.IsNotNull(ownerWrapper);
            Assert.IsTrue(ownerWrapper.Equals(owner));
            Assert.AreEqual(owner, ownerWrapper.ActualOwner);
            Assert.AreEqual(ownerWrapper, ViewModelExtensions.GetDocumentOwner(button));
        }