public void Execute_Should_Write_To_Console_You_Open_The_Plus_All_But_First_Word_Plus_Ending_Text() { //Arrange //Act cmd.Execute("open door"); //Assert mock.AssertWasCalled(m => m.WriteLine("You open the {0} and peek at what's inside.", "door")); }
protected override void OnOpened(EventArgs e) { base.OnOpened(e); // Open file dialog directly after app start if (Application.Current is App app && app.Host is not null) { var vm = app.Host.Services.GetService <ActionsPanelViewModel>(); vm !.OpenCommand.Execute().Subscribe(); } }
public void OpenCommandTest() { StartGameCommandTest(); int robotBattery = _context.Robot.BatteryBalance; int mass = _context.Robot.Mass; ICommand openCommand = new OpenCommand(_context); openCommand.Execute(); Assert.IsFalse(robotBattery == _context.Robot.BatteryBalance); Assert.IsFalse(mass == _context.Robot.Mass); Assert.IsTrue(_context.State is DecidingState); }
/// <summary> /// Обрабатывает нажатие клавиши. /// </summary> /// <param name="sender">Объект-отправитель.</param> /// <param name="e">Передаваемые данные.</param> public void OnPageKeyDown(object sender, KeyRoutedEventArgs e) { if (e.Key == VirtualKey.Control) { _isCtrlKeyPressed = true; } if (_isCtrlKeyPressed) { switch (e.Key) { case VirtualKey.O: OpenCommand.Execute(null); break; case VirtualKey.P: PrintCommand.Execute(null); break; } } }
/// <summary> /// Initializes the main window. /// </summary> private void InitializeMainWindow() { Loaded += MainWindow_Loaded; UrlTextBox.Text = HistoryItems.Count > 0 ? HistoryItems.First() : string.Empty; // If you don't want to show the first frame upon loading. // Media.ScrubbingEnabled = false; // Media.LoadedBehavior = MediaState.Pause; // Open a file if it is specified in the arguments var args = Environment.GetCommandLineArgs(); if (args != null && args.Length > 1) { UrlTextBox.Text = args[1].Trim(); OpenCommand.Execute(); } OpenMediaPopup.Opened += (s, e) => { if (UrlTextBox.ItemsSource == null) { UrlTextBox.ItemsSource = HistoryItems; } if (HistoryItems.Count > 0) { UrlTextBox.Text = HistoryItems.First(); } UrlTextBox.Focus(); }; UrlTextBox.KeyDown += (s, e) => { if (e.Key == Key.Enter) { OpenCommand.Execute(); e.Handled = true; } }; }
/// <summary> /// Initializes the main window. /// </summary> private void InitializeMainWindow() { Loaded += MainWindow_Loaded; UrlTextBox.Text = HistoryItems.Count > 0 ? HistoryItems.First() : string.Empty; OpenMediaPopup.Opened += (s, e) => { if (UrlTextBox.ItemsSource == null) { UrlTextBox.ItemsSource = HistoryItems; } if (HistoryItems.Count > 0) { UrlTextBox.Text = HistoryItems.First(); } UrlTextBox.Focus(); }; UrlTextBox.KeyDown += async(s, e) => { if (e.Key == Key.Enter) { await OpenCommand.ExecuteAsync(); e.Handled = true; } }; // Open a file if it is specified in the arguments var args = Environment.GetCommandLineArgs(); if (args != null && args.Length > 1) { UrlTextBox.Text = args[1].Trim(); OpenCommand.Execute(); } }
/// <summary> /// Initializes the main window. /// </summary> private void InitializeMainWindow() { Loaded += MainWindow_Loaded; OpenFileTextBox.KeyDown += async(s, e) => { if (e.Key == Key.Enter) { await OpenCommand.ExecuteAsync(); e.Handled = true; } }; // Open a file if it is specified in the arguments var args = Environment.GetCommandLineArgs(); if (args != null && args.Length > 1) { OpenFileTextBox.Text = args[1].Trim(); OpenCommand.Execute(); } }
private void setupCommands() { ContextMenuCommand = new SimpleCommand() { ExecuteDelegate = (x) => { NavigationItemViewModel <FI, DI, FSI> vm = this; Point pt = UITools.GetScreenMousePosition(); switch (vm.ContextMenu(pt)) { case "open": if (OpenCommand != null) { OpenCommand.Execute(vm); } break; case "rename": if (RenameCommand != null) { RenameCommand.Execute(vm); } break; case "refresh": if (RefreshCommand != null) { RefreshCommand.Execute(vm); } break; } } }; OpenCommand = new SimpleCommand() { ExecuteDelegate = (x) => { Profile.Open(EmbeddedDirectoryModel); } }; RefreshCommand = new SimpleCommand() { CanExecuteDelegate = (x) => { return(_subDirectories != null && !_subDirectories.IsWorking); }, ExecuteDelegate = (x) => { Refresh(); } }; PropertiesCommand = new SimpleCommand() { ExecuteDelegate = x => { System.Windows.Point position = Mouse.GetPosition(null); Profile.ShowProperties(position, EmbeddedDirectoryModel); } }; RenameCommand = new SimpleCommand() { CanExecuteDelegate = (x) => { return(!this.EmbeddedDirectoryModel.IsReadonly); }, ExecuteDelegate = (x) => { EmbeddedDirectoryViewModel.IsEditing = true; } }; DeleteCommand = new SimpleCommand() { CanExecuteDelegate = (x) => { return(EmbeddedDirectoryModel.IsReadonly); }, ExecuteDelegate = (x) => { try { string caption = String.Format(Texts.strConfirmDelete, 1, ""); if (new WPFMessageBoxService().ShowYesNo(caption, CustomDialogIcons.Question) == CustomDialogResults.Yes) { Profile.Delete(EmbeddedDirectoryModel, EmbeddedDirectoryViewModel.EmbeddedDirectoryModel); } } catch (Exception ex) { new WPFMessageBoxService().ShowError(ex.Message); } } }; }