Ejemplo n.º 1
0
        public void CanDeactivate_View_And_ViewModel()
        {
            var  view      = new MyViewCanDeactivate();
            var  viewModel = view.DataContext as MyViewModelCanDeactivate;
            bool?success   = null;

            view.Reset();
            view.CDeactivate = false;
            success          = NavigationHelper.CanDeactivate(view, new NavigationContext(typeof(MyViewCanDeactivate), "p")); // false
            Assert.AreEqual(true, view.IsCanDeactivateInvoked);
            Assert.AreEqual(false, viewModel.IsCanDeactivateInvoked);
            Assert.AreEqual(false, success);

            view.Reset();
            viewModel.Reset();
            success = null;
            viewModel.CDeactivate = false;
            success = NavigationHelper.CanDeactivate(view, new NavigationContext(typeof(MyViewCanDeactivate), "p2")); // false
            Assert.AreEqual(true, view.IsCanDeactivateInvoked);
            Assert.AreEqual(true, viewModel.IsCanDeactivateInvoked);
            Assert.AreEqual(false, success);

            view.Reset();
            viewModel.Reset();
            success = null;
            success = NavigationHelper.CanDeactivate(view, new NavigationContext(typeof(MyViewCanDeactivate), "p3"));;  // true
            Assert.AreEqual(true, view.IsCanDeactivateInvoked);
            Assert.AreEqual(true, viewModel.IsCanDeactivateInvoked);
            Assert.AreEqual(true, success);
        }
Ejemplo n.º 2
0
        public void Delayed_CanDeactivate()
        {
            var  viewModel = new DelayedViewModel();
            bool?success   = null;

            viewModel.CDeactivate = false;
            success = NavigationHelper.CanDeactivate(viewModel, new NavigationContext(typeof(MyViewModelCanActivate), "p")); // false
            Assert.AreEqual(false, success);

            viewModel.CDeactivate = true;
            success = NavigationHelper.CanDeactivate(viewModel, new NavigationContext(typeof(MyViewModelCanActivate), "p2")); // true
            Assert.AreEqual(true, success);
        }