Skip to content

Commit 0072b7e

Browse files
yorahnulltoken
authored andcommitted
Replace AssertExtensions.ShouldBeNull method by Assert.Null
1 parent b9bd9c8 commit 0072b7e

File tree

10 files changed

+31
-36
lines changed

10 files changed

+31
-36
lines changed

LibGit2Sharp.Tests/BranchFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public void TrackingInformationIsEmptyForNonTrackingBranch()
282282
{
283283
Branch branch = repo.Branches["test"];
284284
Assert.False(branch.IsTracking);
285-
branch.TrackedBranch.ShouldBeNull();
285+
Assert.Null(branch.TrackedBranch);
286286
Assert.Equal(0, branch.AheadBy);
287287
Assert.Equal(0, branch.BehindBy);
288288
}
@@ -530,12 +530,12 @@ public void CanMoveABranch()
530530
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo();
531531
using (var repo = new Repository(path.RepositoryPath))
532532
{
533-
repo.Branches["br3"].ShouldBeNull();
533+
Assert.Null(repo.Branches["br3"]);
534534

535535
Branch newBranch = repo.Branches.Move("br2", "br3");
536536
Assert.Equal("br3", newBranch.Name);
537537

538-
repo.Branches["br2"].ShouldBeNull();
538+
Assert.Null(repo.Branches["br2"]);
539539
repo.Branches["br3"].ShouldNotBeNull();
540540
}
541541
}
@@ -564,7 +564,7 @@ public void CanMoveABranchWhileOverwritingAnExistingOne()
564564
Branch newBranch = repo.Branches.Move("br2", "test", true);
565565
Assert.Equal("test", newBranch.Name);
566566

567-
repo.Branches["br2"].ShouldBeNull();
567+
Assert.Null(repo.Branches["br2"]);
568568

569569
Branch newTest = repo.Branches["test"];
570570
newTest.ShouldNotBeNull();

LibGit2Sharp.Tests/CommitFixture.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ public void DirectlyAccessingAnUnknownTreeEntryOfTheCommitReturnsNull()
435435
{
436436
var commit = repo.Lookup<Commit>("4c062a6");
437437

438-
commit["I-am-not-here"].ShouldBeNull();
438+
Assert.Null(commit["I-am-not-here"]);
439439
}
440440
}
441441

@@ -460,7 +460,7 @@ public void CanCommitWithSignatureFromConfig()
460460
File.AppendAllText(filePath, "token\n");
461461
repo.Index.Stage(relativeFilepath);
462462

463-
repo.Head[relativeFilepath].ShouldBeNull();
463+
Assert.Null(repo.Head[relativeFilepath]);
464464

465465
Commit commit = repo.Commit("Initial egotistic commit");
466466

@@ -495,7 +495,7 @@ public void CanCommitALittleBit()
495495
File.AppendAllText(filePath, "token\n");
496496
repo.Index.Stage(relativeFilepath);
497497

498-
repo.Head[relativeFilepath].ShouldBeNull();
498+
Assert.Null(repo.Head[relativeFilepath]);
499499

500500
var author = DummySignature;
501501
Commit commit = repo.Commit("Initial egotistic commit", author, author);

LibGit2Sharp.Tests/ConfigurationFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public void ReadingValueThatDoesntExistReturnsDefault()
268268
{
269269
using (var repo = new Repository(StandardTestRepoPath))
270270
{
271-
repo.Config.Get<string>("unittests.ghostsetting", null).ShouldBeNull();
271+
Assert.Null(repo.Config.Get<string>("unittests.ghostsetting", null));
272272
Assert.Equal(0, repo.Config.Get<int>("unittests.ghostsetting", 0));
273273
Assert.Equal(0L, repo.Config.Get<long>("unittests.ghostsetting", 0L));
274274
Assert.False(repo.Config.Get<bool>("unittests.ghostsetting", false));

LibGit2Sharp.Tests/IndexFixture.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void FetchingAnUnknownIndexEntryReturnsNull()
6868
using (var repo = new Repository(StandardTestRepoPath))
6969
{
7070
IndexEntry entry = repo.Index["I-do-not-exist.txt"];
71-
entry.ShouldBeNull();
71+
Assert.Null(entry);
7272
}
7373
}
7474

@@ -137,7 +137,7 @@ public void StagingAnUnknownFileThrows(string relativePath, FileStatus status)
137137
{
138138
using (var repo = new Repository(StandardTestRepoPath))
139139
{
140-
repo.Index[relativePath].ShouldBeNull();
140+
Assert.Null(repo.Index[relativePath]);
141141
Assert.Equal(status, repo.Index.RetrieveStatus(relativePath));
142142

143143
Assert.Throws<LibGit2Exception>(() => repo.Index.Stage(relativePath));
@@ -160,7 +160,7 @@ public void CanStageTheRemovalOfAStagedFile()
160160
Assert.Equal(FileStatus.Added | FileStatus.Missing, repo.Index.RetrieveStatus(filename));
161161

162162
repo.Index.Stage(filename);
163-
repo.Index[filename].ShouldBeNull();
163+
Assert.Null(repo.Index[filename]);
164164

165165
Assert.Equal(count - 1, repo.Index.Count);
166166
Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus(filename));
@@ -201,11 +201,11 @@ public void CanStageANewFileInAPersistentManner()
201201
{
202202
const string filename = "unit_test.txt";
203203
Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus(filename));
204-
repo.Index[filename].ShouldBeNull();
204+
Assert.Null(repo.Index[filename]);
205205

206206
File.WriteAllText(Path.Combine(repo.Info.WorkingDirectory, filename), "some contents");
207207
Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(filename));
208-
repo.Index[filename].ShouldBeNull();
208+
Assert.Null(repo.Index[filename]);
209209

210210
repo.Index.Stage(filename);
211211
repo.Index[filename].ShouldNotBeNull();

LibGit2Sharp.Tests/ReferenceFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public void ADeletedReferenceCannotBeLookedUp()
163163
const string refName = "refs/heads/test";
164164

165165
repo.Refs.Delete(refName);
166-
repo.Refs[refName].ShouldBeNull();
166+
Assert.Null(repo.Refs[refName]);
167167
}
168168
}
169169

@@ -461,7 +461,7 @@ public void CanMoveAndOverWriteAExistingReference()
461461

462462
Reference moved = repo.Refs.Move(oldName, newName, true);
463463

464-
repo.Refs[oldName].ShouldBeNull();
464+
Assert.Null(repo.Refs[oldName]);
465465
repo.Refs[moved.CanonicalName].ShouldNotBeNull();
466466
}
467467
}

LibGit2Sharp.Tests/RemoteFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public void GettingRemoteThatDoesntExistReturnsNull()
2222
{
2323
using (var repo = new Repository(StandardTestRepoPath))
2424
{
25-
repo.Remotes["test"].ShouldBeNull();
25+
Assert.Null(repo.Remotes["test"]);
2626
}
2727
}
2828

LibGit2Sharp.Tests/RepositoryFixture.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void CanCreateBareRepo()
2121
Directory.Exists(dir).ShouldBeTrue();
2222
CheckGitConfigFile(dir);
2323

24-
repo.Info.WorkingDirectory.ShouldBeNull();
24+
Assert.Null(repo.Info.WorkingDirectory);
2525
Assert.Equal(scd.RootedDirectoryPath + Path.DirectorySeparatorChar, repo.Info.Path);
2626
repo.Info.IsBare.ShouldBeTrue();
2727

@@ -104,19 +104,19 @@ private static void AssertInitializedRepository(Repository repo)
104104
Reference headRef = repo.Refs["HEAD"];
105105
headRef.ShouldNotBeNull();
106106
Assert.Equal("refs/heads/master", headRef.TargetIdentifier);
107-
headRef.ResolveToDirectReference().ShouldBeNull();
107+
Assert.Null(headRef.ResolveToDirectReference());
108108

109109
repo.Head.ShouldNotBeNull();
110110
repo.Head.IsCurrentRepositoryHead.ShouldBeTrue();
111111
Assert.Equal(headRef.TargetIdentifier, repo.Head.CanonicalName);
112-
repo.Head.Tip.ShouldBeNull();
112+
Assert.Null(repo.Head.Tip);
113113

114114
Assert.Equal(0, repo.Commits.Count());
115115
Assert.Equal(0, repo.Commits.QueryBy(new Filter { Since = repo.Head }).Count());
116116
Assert.Equal(0, repo.Commits.QueryBy(new Filter { Since = "HEAD" }).Count());
117117
Assert.Equal(0, repo.Commits.QueryBy(new Filter { Since = "refs/heads/master" }).Count());
118118

119-
repo.Head["subdir/I-do-not-exist"].ShouldBeNull();
119+
Assert.Null(repo.Head["subdir/I-do-not-exist"]);
120120

121121
Assert.Equal(0, repo.Branches.Count());
122122
Assert.Equal(0, repo.Refs.Count());
@@ -130,7 +130,7 @@ public void CanOpenBareRepositoryThroughAFullPathToTheGitDir()
130130
using (var repo = new Repository(path))
131131
{
132132
repo.ShouldNotBeNull();
133-
repo.Info.WorkingDirectory.ShouldBeNull();
133+
Assert.Null(repo.Info.WorkingDirectory);
134134
}
135135
}
136136

@@ -160,7 +160,7 @@ public void CanOpenRepository()
160160
using (var repo = new Repository(BareTestRepoPath))
161161
{
162162
repo.Info.Path.ShouldNotBeNull();
163-
repo.Info.WorkingDirectory.ShouldBeNull();
163+
Assert.Null(repo.Info.WorkingDirectory);
164164
repo.Info.IsBare.ShouldBeTrue();
165165
Assert.False(repo.Info.IsEmpty);
166166
Assert.False(repo.Info.IsHeadDetached);
@@ -241,8 +241,8 @@ public void LookupObjectByWrongShaReturnsNull()
241241
{
242242
using (var repo = new Repository(BareTestRepoPath))
243243
{
244-
repo.Lookup(Constants.UnknownSha).ShouldBeNull();
245-
repo.Lookup<GitObject>(Constants.UnknownSha).ShouldBeNull();
244+
Assert.Null(repo.Lookup(Constants.UnknownSha));
245+
Assert.Null(repo.Lookup<GitObject>(Constants.UnknownSha));
246246
}
247247
}
248248

@@ -253,7 +253,7 @@ public void LookupObjectByWrongTypeReturnsNull()
253253
{
254254
repo.Lookup(commitSha).ShouldNotBeNull();
255255
repo.Lookup<Commit>(commitSha).ShouldNotBeNull();
256-
repo.Lookup<TagAnnotation>(commitSha).ShouldBeNull();
256+
Assert.Null(repo.Lookup<TagAnnotation>(commitSha));
257257
}
258258
}
259259

@@ -262,8 +262,8 @@ public void LookupObjectByUnknownReferenceNameReturnsNull()
262262
{
263263
using (var repo = new Repository(BareTestRepoPath))
264264
{
265-
repo.Lookup("refs/heads/chopped/off").ShouldBeNull();
266-
repo.Lookup<GitObject>(Constants.UnknownSha).ShouldBeNull();
265+
Assert.Null(repo.Lookup("refs/heads/chopped/off"));
266+
Assert.Null(repo.Lookup<GitObject>(Constants.UnknownSha));
267267
}
268268
}
269269

@@ -352,7 +352,7 @@ public void DiscoverReturnsNullWhenNoRepoCanBeFound()
352352

353353
SelfCleaningDirectory scd = BuildSelfCleaningDirectory(path + suffix);
354354
Directory.CreateDirectory(scd.RootedDirectoryPath);
355-
Repository.Discover(scd.RootedDirectoryPath).ShouldBeNull();
355+
Assert.Null(Repository.Discover(scd.RootedDirectoryPath));
356356

357357
File.Delete(path);
358358
}

LibGit2Sharp.Tests/TagFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ public void ADeletedTagCannotBeLookedUp()
477477
const string tagName = "e90810b";
478478

479479
repo.Tags.Delete(tagName);
480-
repo.Tags[tagName].ShouldBeNull();
480+
Assert.Null(repo.Tags[tagName]);
481481
}
482482
}
483483

@@ -572,7 +572,7 @@ public void CanLookupALightweightTag()
572572
Assert.Equal(commitE90810BSha, tag.Target.Sha);
573573

574574
Assert.False(tag.IsAnnotated);
575-
tag.Annotation.ShouldBeNull();
575+
Assert.Null(tag.Annotation);
576576
}
577577
}
578578

LibGit2Sharp.Tests/TestHelpers/AssertExtensions.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ public static void ShouldBeAboutEqualTo(this DateTimeOffset expected, DateTimeOf
1414
Assert.Equal(expected.Second, current.Second);
1515
}
1616

17-
public static void ShouldBeNull(this object currentObject)
18-
{
19-
Assert.Null(currentObject);
20-
}
21-
2217
public static void ShouldBeTrue(this bool currentObject)
2318
{
2419
Assert.True(currentObject);

LibGit2Sharp.Tests/TreeFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void GettingAnUknownTreeEntryReturnsNull()
9999
{
100100
var tree = repo.Lookup<Tree>(sha);
101101
TreeEntry treeEntry = tree["I-do-not-exist"];
102-
treeEntry.ShouldBeNull();
102+
Assert.Null(treeEntry);
103103
}
104104
}
105105

0 commit comments

Comments
 (0)