public void Should_update_committer_info_on_form_activated() { RunFormTest(async form => { var commitAuthorStatus = form.GetTestAccessor().CommitAuthorStatusToolStripStatusLabel; Assert.AreEqual("Committer author <*****@*****.**>", commitAuthorStatus.Text); using (var tempForm = new Form()) { tempForm.Owner = form; tempForm.Show(); tempForm.Focus(); _referenceRepository.Module.GitExecutable.GetOutput(@"config user.name ""new author"""); _referenceRepository.Module.GitExecutable.GetOutput(@"config user.email ""*****@*****.**"""); } form.Focus(); await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.AreEqual("Committer new author <*****@*****.**>", commitAuthorStatus.Text); }); }
private void RunSetAndApplyBranchFilterTest(string initialFilter, Action <RevisionGridControl> runTest) { // Disable artificial commits as they appear to destabilise these tests AppSettings.RevisionGraphShowArtificialCommits = false; UITest.RunForm <FormBrowse>( showForm: () => _commands.StartBrowseDialog(owner: null).Should().BeTrue(), runTestAsync: async formBrowse => { DoEvents(); // wait for the revisions to be loaded await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); formBrowse.RevisionGridControl.SetSelectedRevision(ObjectId.Parse(_headCommit)); formBrowse.RevisionGridControl.SetAndApplyBranchFilter(initialFilter); // wait for the revisions to be loaded await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); try { runTest(formBrowse.RevisionGridControl); } catch (Exception ex) { Console.WriteLine($"{runTest.Method.Name} failed: {ex.Demystify()}"); Console.WriteLine(_referenceRepository.Module.GitExecutable.GetOutput("status")); throw; } }); }
public async Task TearDownAsync() { // Wait for pending operations so the repository is not deleted while operations run in the background await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); _repo1.Dispose(); }
private void RunSetAndApplyBranchFilterTest(string initialFilter, Action <RevisionGridControl> runTest) { UITest.RunForm <FormBrowse>( showForm: () => _commands.StartBrowseDialog(owner: null).Should().BeTrue(), runTestAsync: async formBrowse => { DoEvents(); // wait for the revisions to be loaded await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); formBrowse.RevisionGridControl.SetAndApplyBranchFilter(initialFilter); // Refresh the grid, to reflect the filter RefreshRevisions(formBrowse.RevisionGridControl); try { runTest(formBrowse.RevisionGridControl); } catch (Exception ex) { Console.WriteLine($"{runTest.Method.Name} failed: {ex.Demystify()}"); Console.WriteLine(_referenceRepository.Module.GitExecutable.GetOutput("status")); throw; } }); }
private void RunCommitInfoTest(Action <GitUI.CommitInfo.CommitInfo> runTest) { UITest.RunControl( createControl: form => { var uiCommandsSource = Substitute.For <IGitUICommandsSource>(); uiCommandsSource.UICommands.Returns(x => _commands); // the following assignment of CommitInfo.UICommandsSource will already call this command _gitExecutable.StageOutput("for-each-ref --sort=-taggerdate --format=\"%(refname)\" refs/tags/", ""); return(new GitUI.CommitInfo.CommitInfo { Parent = form, UICommandsSource = uiCommandsSource }); }, runTestAsync: async commitInfo => { // Wait for pending operations so the Control is loaded completely before testing it await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); runTest(commitInfo); }); }
public async Task TearDownAsync() { // Wait for pending operations so the repository is not deleted while operations run in the background await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); //// _provider is a singleton and must not be disposed _repo1.Dispose(); _repo2.Dispose(); _repo3.Dispose(); }
public async Task FileAndForgetFilterCanIgnoreExceptions() { using var helper = new ThreadExceptionHelper(); var ex = new Exception(); ThrowExceptionAsync(ex).FileAndForget(fileOnlyIf: e => e != ex); await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.Null(helper.Exception, helper.Message); }
public async Task FileAndForgetFilterCanAllowExceptions() { using var helper = new ThreadExceptionHelper(); var ex = new Exception(); ThrowExceptionAsync(ex).FileAndForget(fileOnlyIf: e => e == ex); await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.AreSame(ex, helper.Exception); }
public async Task FileAndForgetReportsThreadException() { using var helper = new ThreadExceptionHelper(); var ex = new Exception(); ThrowExceptionAsync(ex).FileAndForget(); await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.AreSame(ex, helper.Exception); }
public void BuildServerType_should_contain_only_None_if_not_build_server_plugins_found() { RunFormTest( async form => { await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.AreEqual(1, _settingsPage.GetTestAccessor().BuildServerType.Items.Count); Assert.AreEqual(0, _settingsPage.GetTestAccessor().BuildServerType.SelectedIndex); }); }
public void BuildServerType_should_contain_discovered_build_server_plugins() { RunFormTest( async form => { await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.AreEqual(/* default None + GenericBuildServerMock */ 2, _settingsPage.GetTestAccessor().BuildServerType.Items.Count); Assert.AreEqual(0, _settingsPage.GetTestAccessor().BuildServerType.SelectedIndex); Assert.AreEqual("GenericBuildServerMock", _settingsPage.GetTestAccessor().BuildServerType.Items[1]); }); }
public async Task FileAndForgetIgnoresCancellationExceptions() { using ThreadExceptionHelper helper = new(); Form form = new(); form.Dispose(); YieldOntoControlMainThreadAsync(form).FileAndForget(); await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.Null(helper.Exception, helper.Message); }
public async Task FileAndForgetFilterIgnoresCancellationExceptions() { using var helper = new ThreadExceptionHelper(); var form = new Form(); form.Dispose(); YieldOntoControlMainThreadAsync(form).FileAndForget(fileOnlyIf: ex => true); await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.Null(helper.Exception, helper.Message); }
public void Should_display_branch_and_no_remote_info_in_statusbar() { _referenceRepository.CheckoutMaster(); RunFormTest(async form => { await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); var currentBranchNameLabelStatus = form.GetTestAccessor().CurrentBranchNameLabelStatus; var remoteNameLabelStatus = form.GetTestAccessor().RemoteNameLabelStatus; Assert.AreEqual("master →", currentBranchNameLabelStatus.Text); Assert.AreEqual("(remote not configured)", remoteNameLabelStatus.Text); }); }
public void editFileToolStripMenuItem_Click_no_selection_should_not_throw() { RunFormTest(async form => { await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); form.GetTestAccessor().UnstagedList.ClearSelected(); var editFileToolStripMenuItem = form.GetTestAccessor().EditFileToolStripMenuItem; // asserting by the virtue of not crashing editFileToolStripMenuItem.PerformClick(); }); }
public void BuildServerType_should_toggle_plugin_settings_controls() { RunFormTest( async form => { await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); // Default option, no custom control Assert.AreEqual(0, _settingsPage.GetTestAccessor().buildServerSettingsPanel.Controls.Count); // Select the custom build server _settingsPage.GetTestAccessor().BuildServerType.SelectedIndex = 1; Assert.AreEqual(1, _settingsPage.GetTestAccessor().buildServerSettingsPanel.Controls.Count); Assert.IsInstanceOf <IBuildServerSettingsUserControl>(_settingsPage.GetTestAccessor().buildServerSettingsPanel.Controls[0]); }); }
public void RunScript_with_arguments_with_s_option_with_RevisionGrid_with_selection_shall_succeed() { _exampleScript.Command = "cmd"; _exampleScript.Arguments = "/c echo {sHash}"; _referenceRepository.CheckoutRevision(); RunFormTest(async formBrowse => { // wait until the revisions are loaded await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); Assert.AreEqual(1, formBrowse.RevisionGridControl.GetSelectedRevisions().Count); string errorMessage = null; var result = ScriptRunner.RunScript(formBrowse, _referenceRepository.Module, _keyOfExampleScript, _uiCommands, formBrowse.RevisionGridControl, error => errorMessage = error); errorMessage.Should().BeNull(); result.Should().BeEquivalentTo(new CommandStatus(executed: true, needsGridRefresh: false)); }); }
public void Should_display_detached_head_info_in_statusbar() { _referenceRepository.CheckoutRevision(); RunFormTest(async form => { await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); var currentBranchNameLabelStatus = form.GetTestAccessor().CurrentBranchNameLabelStatus; var remoteNameLabelStatus = form.GetTestAccessor().RemoteNameLabelStatus; // For a yet unknown cause randomly, the wait in UITest.RunForm does not suffice. if (!string.IsNullOrEmpty(remoteNameLabelStatus.Text)) { Console.WriteLine($"{nameof(Should_display_detached_head_info_in_statusbar)} waits again"); await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); } Assert.AreEqual("(no branch)", currentBranchNameLabelStatus.Text); Assert.AreEqual(string.Empty, remoteNameLabelStatus.Text); }); }
private void RunToggleBetweenArtificialAndHeadCommitsTest(bool showGitStatusForArtificialCommits, Action <RevisionGridControl> runTest) { AppSettings.ShowGitStatusForArtificialCommits = showGitStatusForArtificialCommits; UITest.RunForm <FormBrowse>( showForm: () => _commands.StartBrowseDialog(owner: null).Should().BeTrue(), runTestAsync: async formBrowse => { DoEvents(); // wait for the revisions to be loaded await AsyncTestHelper.JoinPendingOperationsAsync(AsyncTestHelper.UnexpectedTimeout); formBrowse.RevisionGridControl.LatestSelectedRevision.Guid.Should().Be(_headCommit); var ta = formBrowse.GetTestAccessor(); ta.CommitInfoTabControl.SelectedTab = ta.TreeTabPage; // let the focus events be handled DoEvents(); try { runTest(formBrowse.RevisionGridControl); } catch (Exception ex) { Console.WriteLine($"{runTest.Method.Name} failed: {ex.Demystify()}"); Console.WriteLine(_referenceRepository.Module.GitExecutable.GetOutput("status")); throw; } // let the focus events be handled DoEvents(); Assert.IsTrue(ta.CommitInfoTabControl.SelectedTab == ta.DiffTabPage, "Diff tab should be active"); }); }