public ApplicationController(CompositionContainer container, IPresentationService presentationService, IMessageService messageService, ShellService shellService, ProxyController proxyController, DataController dataController) { InitializeCultures(); presentationService.InitializeCultures(); this.container = container; this.dataController = dataController; this.proxyController = proxyController; this.messageService = messageService; this.dataService = container.GetExportedValue<IDataService>(); this.floatingViewModel = container.GetExportedValue<FloatingViewModel>(); this.mainViewModel = container.GetExportedValue<MainViewModel>(); this.userBugsViewModel = container.GetExportedValue<UserBugsViewModel>(); this.teamBugsViewModel = container.GetExportedValue<TeamBugsViewModel>(); shellService.MainView = mainViewModel.View; shellService.UserBugsView = userBugsViewModel.View; shellService.TeamBugsView = teamBugsViewModel.View; this.floatingViewModel.Closing += FloatingViewModelClosing; this.showMainWindowCommand = new DelegateCommand(ShowMainWindowCommandExcute); this.englishCommand = new DelegateCommand(() => SelectLanguage(new CultureInfo("en-US"))); this.chineseCommand = new DelegateCommand(() => SelectLanguage(new CultureInfo("zh-CN"))); this.settingCommand = new DelegateCommand(SettingDialogCommandExcute, CanSettingDialogCommandExcute); this.aboutCommand = new DelegateCommand(AboutDialogCommandExcute); this.exitCommand = new DelegateCommand(ExitCommandExcute); }
public void LanguageSettingsTest() { Settings.Default.Culture = "en-US"; Settings.Default.UICulture = "en-US"; ApplicationController applicationController = Container.GetExportedValue <IApplicationController>() as ApplicationController; Assert.AreEqual(new CultureInfo("en-US"), CultureInfo.CurrentCulture); Assert.AreEqual(new CultureInfo("en-US"), CultureInfo.CurrentUICulture); applicationController.Initialize(); applicationController.Run(); FloatingViewModel floatingViewModel = Container.GetExportedValue <FloatingViewModel>(); floatingViewModel.ChineseCommand.Execute(null); Assert.AreEqual(new CultureInfo("zh-CN"), applicationController.NewLanguage); bool settingsSaved = false; Settings.Default.SettingsSaving += (sender, e) => { settingsSaved = true; }; applicationController.ShutDown(); Assert.AreEqual("zh-CN", Settings.Default.UICulture); Assert.IsTrue(settingsSaved); }
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 ApplicationController(CompositionContainer container, IPresentationService presentationService, IMessageService messageService, ShellService shellService, ProxyController proxyController, DataController dataController) { InitializeCultures(); presentationService.InitializeCultures(); this.container = container; this.dataController = dataController; this.proxyController = proxyController; this.messageService = messageService; this.dataService = container.GetExportedValue <IDataService>(); this.floatingViewModel = container.GetExportedValue <FloatingViewModel>(); this.mainViewModel = container.GetExportedValue <MainViewModel>(); this.userBugsViewModel = container.GetExportedValue <UserBugsViewModel>(); this.teamBugsViewModel = container.GetExportedValue <TeamBugsViewModel>(); shellService.MainView = mainViewModel.View; shellService.UserBugsView = userBugsViewModel.View; shellService.TeamBugsView = teamBugsViewModel.View; this.floatingViewModel.Closing += FloatingViewModelClosing; this.showMainWindowCommand = new DelegateCommand(ShowMainWindowCommandExcute); this.englishCommand = new DelegateCommand(() => SelectLanguage(new CultureInfo("en-US"))); this.chineseCommand = new DelegateCommand(() => SelectLanguage(new CultureInfo("zh-CN"))); this.settingCommand = new DelegateCommand(SettingDialogCommandExcute, CanSettingDialogCommandExcute); this.aboutCommand = new DelegateCommand(AboutDialogCommandExcute); this.exitCommand = new DelegateCommand(ExitCommandExcute); }
protected override void OnInitialize() { FloatingViewModel floatingViewModel = this.container.GetExportedValue <FloatingViewModel>(); MainViewModel mainViewModel = this.container.GetExportedValue <MainViewModel>(); floatingViewModel.RefreshBugsCommand = this.refreshBugsCommand; mainViewModel.RefreshBugsCommand = this.refreshBugsCommand; currentSynchronizationTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext(); }
public void SelectLanguageTest() { ApplicationController applicationController = Container.GetExportedValue <IApplicationController>() as ApplicationController; applicationController.Initialize(); applicationController.Run(); FloatingViewModel floatingViewModel = Container.GetExportedValue <FloatingViewModel>(); MainViewModel mainViewModel = Container.GetExportedValue <MainViewModel>(); Assert.IsNull(applicationController.NewLanguage); floatingViewModel.ChineseCommand.Execute(null); Assert.AreEqual("zh-CN", applicationController.NewLanguage.Name); mainViewModel.EnglishCommand.Execute(null); Assert.AreEqual("en-US", applicationController.NewLanguage.Name); }
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(); }
public void PropertiesWithNotification() { FloatingViewModel viewModel = Container.GetExportedValue <FloatingViewModel>(); ICommand exitCommand = new DelegateCommand(() => { }); AssertHelper.PropertyChangedEvent(viewModel, x => x.ExitCommand, () => viewModel.ExitCommand = exitCommand); Assert.AreEqual(exitCommand, viewModel.ExitCommand); ICommand settingCommand = new DelegateCommand(() => { }); AssertHelper.PropertyChangedEvent(viewModel, x => x.SettingCommand, () => viewModel.SettingCommand = settingCommand); Assert.AreEqual(settingCommand, viewModel.SettingCommand); ICommand aboutCommand = new DelegateCommand(() => { }); AssertHelper.PropertyChangedEvent(viewModel, x => x.AboutCommand, () => viewModel.AboutCommand = aboutCommand); Assert.AreEqual(aboutCommand, viewModel.AboutCommand); ICommand refreshBugsCommand = new DelegateCommand(() => { }); AssertHelper.PropertyChangedEvent(viewModel, x => x.RefreshBugsCommand, () => viewModel.RefreshBugsCommand = refreshBugsCommand); Assert.AreEqual(refreshBugsCommand, viewModel.RefreshBugsCommand); ICommand englishCommand = new DelegateCommand(() => { }); AssertHelper.PropertyChangedEvent(viewModel, x => x.EnglishCommand, () => viewModel.EnglishCommand = englishCommand); Assert.AreEqual(englishCommand, viewModel.EnglishCommand); ICommand chineseCommand = new DelegateCommand(() => { }); AssertHelper.PropertyChangedEvent(viewModel, x => x.ChineseCommand, () => viewModel.ChineseCommand = chineseCommand); Assert.AreEqual(chineseCommand, viewModel.ChineseCommand); ICommand showMainWindowCommand = new DelegateCommand(() => { }); AssertHelper.PropertyChangedEvent(viewModel, x => x.ShowMainWindowCommand, () => viewModel.ShowMainWindowCommand = showMainWindowCommand); Assert.AreEqual(showMainWindowCommand, viewModel.ShowMainWindowCommand); IDataService dataService = Container.GetExportedValue <IDataService>(); AssertHelper.PropertyChangedEvent(viewModel, x => x.RedBugCount, () => dataService.UserBugs.Add( new Bug() { ID = 1, Title = "Bug1", Description = "Description for Bug1.", Type = BugType.Red, AssignedTo = "BigEgg", State = "Implement", ChangedDate = new DateTime(2013, 4, 10), CreatedBy = "BigEgg", Priority = "High", Severity = "" } ) ); Assert.AreEqual(viewModel.RedBugCount, 1); AssertHelper.PropertyChangedEvent(viewModel, x => x.YellowBugCount, () => dataService.UserBugs.Add( new Bug() { ID = 6, Title = "Bug6", Description = "Description for Bug6.", AssignedTo = "Pupil", State = "Closed", ChangedDate = new DateTime(2013, 4, 11), CreatedBy = "Pupil", Priority = "High", Severity = "High" } ) ); Assert.AreEqual(viewModel.YellowBugCount, 1); }