public void ShowAndClose() { MockFloatingView view = (MockFloatingView)Container.GetExportedValue <IFloatingView>(); FloatingViewModel viewModel = Container.GetExportedValue <FloatingViewModel>(); // Show the MainView Assert.IsFalse(view.IsVisible); viewModel.Show(); Assert.IsTrue(view.IsVisible); // Try to close the ShellView but cancel this operation through the closing event bool cancelClosing = true; viewModel.Closing += (sender, e) => { e.Cancel = cancelClosing; }; viewModel.Close(); Assert.IsTrue(view.IsVisible); // Close the ShellView via the ExitCommand cancelClosing = false; AssertHelper.PropertyChangedEvent(viewModel, x => x.ExitCommand, () => viewModel.ExitCommand = new DelegateCommand(() => viewModel.Close())); viewModel.ExitCommand.Execute(null); Assert.IsFalse(view.IsVisible); }
public void RestoreWindowLocationAndSizeSpecial() { DataService dataService = new DataService(); MockPresentationService presentationService = (MockPresentationService)Container.GetExportedValue <IPresentationService>(); presentationService.VirtualScreenWidth = 1000; presentationService.VirtualScreenHeight = 700; FloatingViewModel viewModel = Container.GetExportedValue <FloatingViewModel>(); MockFloatingView view = (MockFloatingView)Container.GetExportedValue <IFloatingView>(); view.SetNAForLocationAndSize(); SetSettingsValues(); new FloatingViewModel(view, dataService, presentationService).Close(); AssertSettingsValues(0, 0); // Left = 881 + Width(120) = 901 > VirtualScreenWidth = 1000 => don't apply the Settings values SetSettingsValues(881, 100); new FloatingViewModel(view, dataService, presentationService).Close(); AssertSettingsValues(0, 0); // Top = 681 + Height(20) = 701 > VirtualScreenWidth = 600 => don't apply the Settings values SetSettingsValues(100, 681); new FloatingViewModel(view, dataService, presentationService).Close(); AssertSettingsValues(0, 0); // Use the limit values => apply the Settings values SetSettingsValues(880, 680); new FloatingViewModel(view, dataService, presentationService).Close(); AssertSettingsValues(880, 680); }
public void ControllerLifecycle() { IApplicationController applicationController = Container.GetExportedValue <IApplicationController>(); applicationController.Initialize(); FloatingViewModel floatingViewModel = Container.GetExportedValue <FloatingViewModel>(); Assert.IsNotNull(floatingViewModel.AboutCommand); Assert.IsNotNull(floatingViewModel.SettingCommand); Assert.IsNotNull(floatingViewModel.ExitCommand); Assert.IsNotNull(floatingViewModel.ChineseCommand); Assert.IsNotNull(floatingViewModel.EnglishCommand); Assert.IsNotNull(floatingViewModel.RefreshBugsCommand); Assert.IsNotNull(floatingViewModel.ShowMainWindowCommand); MainViewModel mainViewModel = Container.GetExportedValue <MainViewModel>(); Assert.IsNotNull(mainViewModel.AboutCommand); Assert.IsNotNull(mainViewModel.SettingCommand); Assert.IsNotNull(mainViewModel.ExitCommand); Assert.IsNotNull(mainViewModel.ChineseCommand); Assert.IsNotNull(mainViewModel.EnglishCommand); Assert.IsNotNull(mainViewModel.RefreshBugsCommand); applicationController.Run(); MockFloatingView floatingView = (MockFloatingView)Container.GetExportedValue <IFloatingView>(); Assert.IsTrue(floatingView.IsVisible); floatingViewModel.ExitCommand.Execute(null); Assert.IsFalse(floatingView.IsVisible); applicationController.ShutDown(); }
public void RestoreWindowLocationAndSize() { MockPresentationService presentationService = (MockPresentationService)Container.GetExportedValue <IPresentationService>(); presentationService.VirtualScreenWidth = 1000; presentationService.VirtualScreenHeight = 700; SetSettingsValues(20, 10); FloatingViewModel viewModel = Container.GetExportedValue <FloatingViewModel>(); MockFloatingView view = (MockFloatingView)Container.GetExportedValue <IFloatingView>(); Assert.AreEqual(20, view.Left); Assert.AreEqual(10, view.Top); view.Left = 25; view.Top = 15; view.Close(); AssertSettingsValues(25, 15); }
public void ShowMainWindowCommandTest() { IApplicationController applicationController = Container.GetExportedValue <IApplicationController>(); applicationController.Initialize(); FloatingViewModel floatingViewModel = Container.GetExportedValue <FloatingViewModel>(); MainViewModel mainViewModel = Container.GetExportedValue <MainViewModel>(); applicationController.Run(); MockFloatingView floatingView = (MockFloatingView)Container.GetExportedValue <IFloatingView>(); MockMainView mainView = (MockMainView)Container.GetExportedValue <IMainView>(); Assert.IsTrue(floatingView.IsVisible); Assert.IsFalse(mainView.IsVisible); floatingViewModel.ShowMainWindowCommand.Execute(null); Assert.IsTrue(mainView.IsVisible); applicationController.ShutDown(); }