Skip to content

Commit d935c49

Browse files
committed
Fix test warnings
1 parent f4fc144 commit d935c49

File tree

3 files changed

+21
-32
lines changed

3 files changed

+21
-32
lines changed

LibGit2Sharp.Tests/ConfigurationFixture.cs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Linq;
55
using LibGit2Sharp.Tests.TestHelpers;
66
using Xunit;
7-
using Xunit.Extensions;
87

98
namespace LibGit2Sharp.Tests
109
{
@@ -56,9 +55,7 @@ public void CanAddAndReadMultivarFromTheLocalConfiguration()
5655
string path = SandboxStandardTestRepo();
5756
using (var repo = new Repository(path))
5857
{
59-
Assert.Empty(repo.Config
60-
.OfType<ConfigurationEntry<string>>()
61-
.Where(x => x.Key == "unittests.plugin"));
58+
Assert.DoesNotContain(repo.Config.OfType<ConfigurationEntry<string>>(), x => x.Key == "unittests.plugin");
6259

6360
repo.Config.Add("unittests.plugin", "value1", ConfigurationLevel.Local);
6461
repo.Config.Add("unittests.plugin", "value2", ConfigurationLevel.Local);
@@ -78,9 +75,7 @@ public void CanAddAndReadMultivarFromTheGlobalConfiguration()
7875
using (var repo = new Repository(path))
7976
{
8077
Assert.True(repo.Config.HasConfig(ConfigurationLevel.Global));
81-
Assert.Empty(repo.Config
82-
.OfType<ConfigurationEntry<string>>()
83-
.Where(x => x.Key == "unittests.plugin"));
78+
Assert.DoesNotContain(repo.Config.OfType<ConfigurationEntry<string>>(), x => x.Key == "unittests.plugin");
8479

8580
repo.Config.Add("unittests.plugin", "value1", ConfigurationLevel.Global);
8681
repo.Config.Add("unittests.plugin", "value2", ConfigurationLevel.Global);
@@ -157,9 +152,7 @@ public void CanUnsetAllFromTheLocalConfiguration()
157152

158153
repo.Config.UnsetAll("unittests.plugin");
159154

160-
Assert.Empty(repo.Config
161-
.OfType<ConfigurationEntry<string>>()
162-
.Where(x => x.Key == "unittests.plugin"));
155+
Assert.DoesNotContain(repo.Config.OfType<ConfigurationEntry<string>>(), x => x.Key == "unittests.plugin");
163156
}
164157
}
165158

@@ -531,20 +524,20 @@ public void CanSetAndGetSearchPath()
531524
{
532525
string globalPath = Path.Combine(Constants.TemporaryReposPath, Path.GetRandomFileName());
533526
string systemPath = Path.Combine(Constants.TemporaryReposPath, Path.GetRandomFileName());
534-
string xdgPath = Path.Combine(Constants.TemporaryReposPath, Path.GetRandomFileName());
527+
string xdgPath = Path.Combine(Constants.TemporaryReposPath, Path.GetRandomFileName());
535528

536529
GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Global, globalPath);
537530
GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.System, systemPath);
538-
GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Xdg, xdgPath);
531+
GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Xdg, xdgPath);
539532

540533
Assert.Equal(globalPath, GlobalSettings.GetConfigSearchPaths(ConfigurationLevel.Global).Single());
541534
Assert.Equal(systemPath, GlobalSettings.GetConfigSearchPaths(ConfigurationLevel.System).Single());
542-
Assert.Equal(xdgPath, GlobalSettings.GetConfigSearchPaths(ConfigurationLevel.Xdg).Single());
535+
Assert.Equal(xdgPath, GlobalSettings.GetConfigSearchPaths(ConfigurationLevel.Xdg).Single());
543536

544537
// reset the search paths to their defaults
545538
GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Global, null);
546539
GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.System, null);
547-
GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Xdg, null);
540+
GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Xdg, null);
548541
}
549542

550543
[Fact]
@@ -577,12 +570,12 @@ public void CanResetSearchPaths()
577570
var newPaths = new string[] { Path.Combine(Constants.TemporaryReposPath, Path.GetRandomFileName()) };
578571

579572
// change to the non-default path
580-
GlobalSettings.SetConfigSearchPaths (ConfigurationLevel.Global, newPaths);
581-
Assert.Equal (newPaths, GlobalSettings.GetConfigSearchPaths (ConfigurationLevel.Global));
573+
GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Global, newPaths);
574+
Assert.Equal(newPaths, GlobalSettings.GetConfigSearchPaths(ConfigurationLevel.Global));
582575

583576
// set it back to the default
584-
GlobalSettings.SetConfigSearchPaths (ConfigurationLevel.Global, null);
585-
Assert.Equal (oldPaths, GlobalSettings.GetConfigSearchPaths (ConfigurationLevel.Global));
577+
GlobalSettings.SetConfigSearchPaths(ConfigurationLevel.Global, null);
578+
Assert.Equal(oldPaths, GlobalSettings.GetConfigSearchPaths(ConfigurationLevel.Global));
586579
}
587580

588581
[Fact]

LibGit2Sharp.Tests/FilterBranchFixture.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Linq;
44
using LibGit2Sharp.Tests.TestHelpers;
55
using Xunit;
6-
using Xunit.Extensions;
76

87
namespace LibGit2Sharp.Tests
98
{
@@ -162,10 +161,8 @@ public void CanRewriteAuthorOfCommits()
162161

163162
AssertSucceedingButNotError();
164163

165-
var nonBackedUpRefs = repo.Refs.Where(
166-
x => !x.CanonicalName.StartsWith("refs/original/") && !x.CanonicalName.StartsWith("refs/notes/"));
167-
Assert.Empty(repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = nonBackedUpRefs })
168-
.Where(c => c.Author.Name != "Ben Straub"));
164+
var nonBackedUpRefs = repo.Refs.Where(x => !x.CanonicalName.StartsWith("refs/original/") && !x.CanonicalName.StartsWith("refs/notes/"));
165+
Assert.DoesNotContain(repo.Commits.QueryBy(new CommitFilter { IncludeReachableFrom = nonBackedUpRefs }), c => c.Author.Name != "Ben Straub");
169166
}
170167

171168
[Fact]
@@ -236,7 +233,7 @@ public void CanRewriteTreesByInjectingTreeEntry()
236233

237234
Assert.Equal(Array.Empty<Commit>(),
238235
repo.Commits
239-
.QueryBy(new CommitFilter {IncludeReachableFrom = repo.Branches})
236+
.QueryBy(new CommitFilter { IncludeReachableFrom = repo.Branches })
240237
.Where(c => c["README"] != null
241238
&& c["README"].Target.Id != currentReadme.Target.Id)
242239
.ToArray());
@@ -403,9 +400,9 @@ public void CanCustomizeTheNamespaceOfBackedUpRefs(string backupRefsNamespace)
403400

404401
AssertSucceedingButNotError();
405402

406-
Assert.NotEmpty(repo.Refs.Where(x => x.CanonicalName.StartsWith("refs/original")));
403+
Assert.DoesNotContain(repo.Refs, x => x.CanonicalName.StartsWith("refs/original"));
407404

408-
Assert.Empty(repo.Refs.Where(x => x.CanonicalName.StartsWith("refs/rewritten")));
405+
Assert.DoesNotContain(repo.Refs, x => x.CanonicalName.StartsWith("refs/rewritten"));
409406

410407
repo.Refs.RewriteHistory(new RewriteHistoryOptions
411408
{
@@ -418,7 +415,7 @@ public void CanCustomizeTheNamespaceOfBackedUpRefs(string backupRefsNamespace)
418415

419416
AssertSucceedingButNotError();
420417

421-
Assert.NotEmpty(repo.Refs.Where(x => x.CanonicalName.StartsWith("refs/rewritten")));
418+
Assert.DoesNotContain(repo.Refs, x => x.CanonicalName.StartsWith("refs/rewritten"));
422419
}
423420

424421
[Fact]
@@ -494,7 +491,7 @@ public void DoesNotRewriteRefsThatDontChange()
494491
// Ensure br2 is still a merge commit
495492
var parents = repo.Branches["br2"].Tip.Parents.ToList();
496493
Assert.Equal(2, parents.Count());
497-
Assert.NotEmpty(parents.Where(c => c.Sha.StartsWith("9fd738e")));
494+
Assert.DoesNotContain(parents, c => c.Sha.StartsWith("9fd738e"));
498495
Assert.Equal("abc", parents.Single(c => !c.Sha.StartsWith("9fd738e")).Message);
499496
}
500497

@@ -535,7 +532,7 @@ public void CanNotOverWriteBackedUpReferences()
535532
var newOriginalRefs = repo.Refs.FromGlob("refs/original/*").OrderBy(r => r.CanonicalName).ToArray();
536533
Assert.Equal(originalRefs, newOriginalRefs);
537534

538-
Assert.Empty(repo.Refs.Where(x => x.CanonicalName.StartsWith("refs/original/original/")));
535+
Assert.DoesNotContain(repo.Refs, x => x.CanonicalName.StartsWith("refs/original/original/"));
539536
}
540537

541538
[Fact]

LibGit2Sharp.Tests/ResetIndexFixture.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.IO;
21
using System.Linq;
32
using LibGit2Sharp.Tests.TestHelpers;
43
using Xunit;
@@ -62,7 +61,7 @@ public void ResetTheIndexWithTheHeadUnstagesEverything()
6261
repo.Index.Replace(repo.Head.Tip);
6362

6463
RepositoryStatus newStatus = repo.RetrieveStatus();
65-
Assert.Empty(newStatus.Where(IsStaged));
64+
Assert.DoesNotContain(newStatus, IsStaged);
6665

6766
// Assert that no reflog entry is created
6867
Assert.Equal(reflogEntriesCount, repo.Refs.Log(repo.Refs.Head).Count());
@@ -120,7 +119,7 @@ public void CanResetTheIndexWhenARenameExists()
120119
repo.Index.Replace(repo.Lookup<Commit>("32eab9c"));
121120

122121
RepositoryStatus status = repo.RetrieveStatus();
123-
Assert.Empty(status.Where(IsStaged));
122+
Assert.DoesNotContain(status, IsStaged);
124123
}
125124
}
126125

0 commit comments

Comments
 (0)