コード例 #1
0
        public void Activatable_User_Control_View_Model_Is_Activated_And_Deactivated()
        {
            var root      = new TestRoot();
            var viewModel = new ActivatableViewModel();
            var control   = new ActivatableUserControl {
                ViewModel = viewModel
            };

            Assert.False(viewModel.IsActivated);

            root.Child = control;
            Assert.True(viewModel.IsActivated);

            root.Child = null;
            Assert.False(viewModel.IsActivated);
        }
コード例 #2
0
        public void Activatable_Window_View_Model_Is_Activated_And_Deactivated()
        {
            using (UnitTestApplication.Start(TestServices.MockWindowingPlatform))
            {
                var viewModel = new ActivatableViewModel();
                var window    = new ActivatableWindow {
                    ViewModel = viewModel
                };
                Assert.False(viewModel.IsActivated);

                window.Show();
                Assert.True(viewModel.IsActivated);

                window.Close();
                Assert.False(viewModel.IsActivated);
            }
        }