public MainWindowViewModel( ShellModuleConfiguration config, IGpxViewerCommands gpxViewerCommands, IGpxViewerSkinService skinService) { this.Configuration = config; this.GpxViewerCommands = gpxViewerCommands; _srvSkin = skinService; // Apply initial skin if ((!string.IsNullOrEmpty(config.Skin)) && (Enum.TryParse(typeof(AppSkin), config.Skin, true, out var parseResult)) && (parseResult is AppSkin configuredSkin)) { _srvSkin.Skin = configuredSkin; } // Update application title string this.Title = FirLibApplication.IsLoaded ? FirLibApplication.Current.ProductFullName : string.Empty; // Handle skin change this.Command_SetSkin = new DelegateCommand <string>(this.OnCommand_SetSkin_Execute); this.Command_LoadRecentlyOpened = new DelegateCommand <RecentlyOpenedInfo>(this.OnCommand_LoadRecentlyOpened_Execute); this.Command_ShowAboutDialog = new DelegateCommand(async() => { var srvAboutDlg = this.GetViewService <IAboutDialogService>(); await srvAboutDlg.ShowAboutDialogAsync(); }); this.Command_Exit = new DelegateCommand(this.OnCommand_Exit_Execute); }
public void Check_SetSkinByCommand() { // Create fakes var skinSet = false; var fakedSkinService = A.Fake <IGpxViewerSkinService>(); A.CallToSet(() => fakedSkinService.Skin).To(AppSkin.Light) .Invokes(_ => skinSet = true); var shellConfig = new ShellModuleConfiguration(); shellConfig.Skin = AppSkin.Dark.ToString(); // Register fakes on container _container.RegisterDelegate(_ => shellConfig); _container.RegisterDelegate(_ => fakedSkinService); // Execute tests var mainWindowVM = _container.Resolve <MainWindowViewModel>(); mainWindowVM.Command_SetSkin.Execute(AppSkin.Light.ToString()); // Check result Assert.IsTrue(skinSet); }