コード例 #1
0
        public void Execute_SenderImplementsINavigate_NavigatesToSender()
        {
            // Arrange
            TestVisualTreeHelper visualTreeHelper = new TestVisualTreeHelper();
            NavigateToPageAction action = new NavigateToPageAction(visualTreeHelper);
            action.TargetPage = NavigateToPageActionTest.TestPageName;
            NavigableStub navigateTarget = new NavigableStub();

            // Act
            bool success = (bool)action.Execute(navigateTarget, null);

            // Assert
            Assert.IsTrue(success);
            Assert.AreEqual(NavigateToPageActionTest.TestPageName, navigateTarget.NavigatedTypeFullName);
        }
コード例 #2
0
        public void Execute_NoAncestorImplementsINavigate_Fails()
        {
            // Arrange
            TestVisualTreeHelper visualTreeHelper = new TestVisualTreeHelper();
            NavigateToPageAction action = new NavigateToPageAction(visualTreeHelper);
            action.TargetPage = NavigateToPageActionTest.TestPageName;
            DependencyObject sender = new SimpleDependencyObject();
            DependencyObject parent = new SimpleDependencyObject();
            visualTreeHelper.AddChild(parent, sender);

            // Act
            bool success = (bool)action.Execute(sender, null);

            // Assert
            Assert.IsFalse(success);
        }
コード例 #3
0
        public void Execute_SenderDoesNotImplementINavigate_NavigatesToAncestor()
        {
            // Arrange
            TestVisualTreeHelper visualTreeHelper = new TestVisualTreeHelper();
            NavigateToPageAction action = new NavigateToPageAction(visualTreeHelper);
            action.TargetPage = NavigateToPageActionTest.TestPageName;
            DependencyObject sender = new SimpleDependencyObject();
            NavigableStub navigateTarget = new NavigableStub();
            visualTreeHelper.AddChild(navigateTarget, sender);

            // Act
            bool success = (bool)action.Execute(sender, null);

            // Assert
            Assert.IsTrue(success);
            Assert.AreEqual(NavigateToPageActionTest.TestPageName, navigateTarget.NavigatedTypeFullName);
        }