Skip to content

Commit

Permalink
fixup! Add test for FilterInfo.Message
Browse files Browse the repository at this point in the history
  • Loading branch information
gerhardol committed Jul 22, 2022
1 parent 96100ff commit d83563f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions GitUI/UserControls/RevisionGrid/FilterInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public string DiffContent

public int CommitsLimitDefault => AppSettings.MaxRevisionGraphCommits;

[System.Diagnostics.DebuggerBrowsable(DebuggerBrowsableState.Never)]
public int CommitsLimit
{
get => ByCommitsLimit && _commitsLimit >= 0 ? _commitsLimit : CommitsLimitDefault;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public void Assert_default_filter_related_settings()

RunSetAndApplyBranchFilterTest(
initialFilter: "",
grepMessage: "",
revisionGridControl =>
{
Assert.False(AppSettings.BranchFilterEnabled);
Expand All @@ -94,6 +95,7 @@ public void Assert_default_filter_related_settings()

RunSetAndApplyBranchFilterTest(
initialFilter: "Branch1",
grepMessage: "",
revisionGridControl =>
{
Assert.True(AppSettings.BranchFilterEnabled);
Expand All @@ -105,6 +107,21 @@ public void Assert_default_filter_related_settings()
revisionGridControl.CurrentFilter.RefFilterOptions.Should().Be(RefFilterOptions.Branches);
});

RunSetAndApplyBranchFilterTest(
initialFilter: "",
grepMessage: "Commit1",
revisionGridControl =>
{
Assert.False(AppSettings.BranchFilterEnabled);
Assert.False(AppSettings.ShowCurrentBranchOnly);
Assert.True(revisionGridControl.CurrentFilter.IsShowAllBranchesChecked);
Assert.False(revisionGridControl.CurrentFilter.IsShowCurrentBranchOnlyChecked);
Assert.False(revisionGridControl.CurrentFilter.IsShowFilteredBranchesChecked);
revisionGridControl.CurrentFilter.RefFilterOptions.Should().Be(RefFilterOptions.None);
});
}

[Test]
Expand All @@ -114,7 +131,8 @@ public void View_reflects_applied_branch_filter()
AppSettings.ShowCurrentBranchOnly = false;

RunSetAndApplyBranchFilterTest(
"",
initialFilter: "",
grepMessage: "",
revisionGridControl =>
{
WaitForRevisionsToBeLoaded(revisionGridControl);
Expand Down Expand Up @@ -144,7 +162,8 @@ public void View_reflects_reset_branch_filter()
AppSettings.ShowCurrentBranchOnly = false;

RunSetAndApplyBranchFilterTest(
"Branch1",
initialFilter: "Branch1",
grepMessage: "",
revisionGridControl =>
{
WaitForRevisionsToBeLoaded(revisionGridControl);
Expand Down Expand Up @@ -307,7 +326,7 @@ public void ToggleBetweenArtificialAndHeadCommits_no_change([Values(false, true)
});
}

private void RunSetAndApplyBranchFilterTest(string initialFilter, Action<RevisionGridControl> runTest)
private void RunSetAndApplyBranchFilterTest(string initialFilter, string grepMessage, Action<RevisionGridControl> runTest)
{
// Disable artificial commits as they appear to destabilise these tests
AppSettings.RevisionGraphShowArtificialCommits = false;
Expand All @@ -323,6 +342,8 @@ private void RunSetAndApplyBranchFilterTest(string initialFilter, Action<Revisio
formBrowse.RevisionGridControl.SetSelectedRevision(ObjectId.Parse(_headCommit)).Should().BeTrue();
formBrowse.RevisionGridControl.CurrentFilter.ByMessage = !string.IsNullOrWhiteSpace(grepMessage);
formBrowse.RevisionGridControl.CurrentFilter.Message = grepMessage;
formBrowse.RevisionGridControl.SetAndApplyBranchFilter(initialFilter);
// wait for the revisions to be loaded
Expand Down

0 comments on commit d83563f

Please sign in to comment.