private async Task RunIsExecutingCommandCommon(IsExecutingCommand command) { void FocusManager_LosingFocus(object sender, LosingFocusEventArgs e) { Assert.Fail("The button should not lose focus when its command is executing"); } try { var(firstButton, secondButton) = await CreateCommandFocusWindowContentAsync(command); firstButton.Focus(FocusState.Programmatic); await TestServices.WindowHelper.WaitForIdle(); FocusManager.LosingFocus += FocusManager_LosingFocus; // Execute command to simulate work await command.SimulateExecutionAsync(); // Focus should stay on the button Assert.AreNotEqual(FocusState.Unfocused, firstButton.FocusState); } finally { FocusManager.LosingFocus -= FocusManager_LosingFocus; } }
public async Task When_Command_Executing_With_Delay_IsEnabled() { var command = new IsExecutingCommand(false); await RunIsExecutingCommandCommon(command); }
public async Task When_Command_Executing_IsEnabled() { var command = new IsExecutingCommand(true); await RunIsExecutingCommandCommon(command); }