Skip to content

Commit d9c7e7a

Browse files
yorahnulltoken
authored andcommitted
Replace AssertExtensions.ShouldNotBeNull method by Assert.NotNull
1 parent e02f76b commit d9c7e7a

13 files changed

+120
-125
lines changed

LibGit2Sharp.Tests/BlobFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public void CanLookUpBlob()
3535
using (var repo = new Repository(BareTestRepoPath))
3636
{
3737
var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6");
38-
blob.ShouldNotBeNull();
38+
Assert.NotNull(blob);
3939
}
4040
}
4141

LibGit2Sharp.Tests/BranchFixture.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ public void CanCreateBranch(string name)
1919
using (var repo = new Repository(path.RepositoryPath))
2020
{
2121
Branch newBranch = repo.CreateBranch(name, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
22-
newBranch.ShouldNotBeNull();
22+
Assert.NotNull(newBranch);
2323
Assert.Equal(name, newBranch.Name);
2424
Assert.Equal("refs/heads/" + name, newBranch.CanonicalName);
25-
newBranch.Tip.ShouldNotBeNull();
25+
Assert.NotNull(newBranch.Tip);
2626
Assert.Equal("be3563ae3f795b2b4353bcce3a527ad0a4f7f644", newBranch.Tip.Sha);
27-
repo.Branches.SingleOrDefault(p => p.Name == name).ShouldNotBeNull();
27+
Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name == name));
2828

2929
repo.Branches.Delete(newBranch.Name);
3030
}
@@ -51,13 +51,13 @@ public void CanCreateBranchFromImplicitHead()
5151
{
5252
const string name = "unit_test";
5353
Branch newBranch = repo.CreateBranch(name);
54-
newBranch.ShouldNotBeNull();
54+
Assert.NotNull(newBranch);
5555
Assert.Equal(name, newBranch.Name);
5656
Assert.Equal("refs/heads/" + name, newBranch.CanonicalName);
5757
Assert.False(newBranch.IsCurrentRepositoryHead);
58-
newBranch.Tip.ShouldNotBeNull();
58+
Assert.NotNull(newBranch.Tip);
5959
Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
60-
repo.Branches.SingleOrDefault(p => p.Name == name).ShouldNotBeNull();
60+
Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name == name));
6161
}
6262
}
6363

@@ -69,7 +69,7 @@ public void CanCreateBranchFromExplicitHead()
6969
{
7070
const string name = "unit_test";
7171
Branch newBranch = repo.CreateBranch(name, "HEAD");
72-
newBranch.ShouldNotBeNull();
72+
Assert.NotNull(newBranch);
7373
Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
7474
}
7575
}
@@ -83,7 +83,7 @@ public void CanCreateBranchFromCommit()
8383
const string name = "unit_test";
8484
var commit = repo.Lookup<Commit>("HEAD");
8585
Branch newBranch = repo.CreateBranch(name, commit);
86-
newBranch.ShouldNotBeNull();
86+
Assert.NotNull(newBranch);
8787
Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
8888
}
8989
}
@@ -96,7 +96,7 @@ public void CreatingABranchFromATagPeelsToTheCommit()
9696
{
9797
const string name = "i-peel-tag";
9898
Branch newBranch = repo.CreateBranch(name, "refs/tags/test");
99-
newBranch.ShouldNotBeNull();
99+
Assert.NotNull(newBranch);
100100
Assert.Equal("e90810b8df3e80c413d903f631643c716887138d", newBranch.Tip.Sha);
101101
}
102102
}
@@ -114,7 +114,7 @@ public void CreatingABranchTriggersTheCreationOfADirectReference()
114114
Assert.Equal(commitId, newBranch.Tip.Id);
115115

116116
Reference reference = repo.Refs[newBranch.CanonicalName];
117-
reference.ShouldNotBeNull();
117+
Assert.NotNull(reference);
118118
Assert.IsType(typeof(DirectReference), reference);
119119
}
120120
}
@@ -221,11 +221,11 @@ public void CanLookupABranchByItsCanonicalName()
221221
using (var repo = new Repository(BareTestRepoPath))
222222
{
223223
Branch branch = repo.Branches["refs/heads/br2"];
224-
branch.ShouldNotBeNull();
224+
Assert.NotNull(branch);
225225
Assert.Equal("br2", branch.Name);
226226

227227
Branch branch2 = repo.Branches["refs/heads/br2"];
228-
branch2.ShouldNotBeNull();
228+
Assert.NotNull(branch2);
229229
Assert.Equal("br2", branch2.Name);
230230

231231
Assert.Equal(branch, branch2);
@@ -239,7 +239,7 @@ public void CanLookupLocalBranch()
239239
using (var repo = new Repository(BareTestRepoPath))
240240
{
241241
Branch master = repo.Branches["master"];
242-
master.ShouldNotBeNull();
242+
Assert.NotNull(master);
243243
Assert.False(master.IsRemote);
244244
Assert.Equal("master", master.Name);
245245
Assert.Equal("refs/heads/master", master.CanonicalName);
@@ -256,10 +256,10 @@ public void CanLookupABranchWhichNameIsMadeOfNon7BitsAsciiCharacters()
256256
{
257257
const string name = "Ångström";
258258
Branch newBranch = repo.CreateBranch(name, "be3563a");
259-
newBranch.ShouldNotBeNull();
259+
Assert.NotNull(newBranch);
260260

261261
Branch retrieved = repo.Branches["Ångström"];
262-
retrieved.ShouldNotBeNull();
262+
Assert.NotNull(retrieved);
263263
Assert.Equal(newBranch.Tip, retrieved.Tip);
264264
}
265265
}
@@ -346,7 +346,7 @@ public void CanCheckoutAnExistingBranch(string name)
346346
Assert.True(master.IsCurrentRepositoryHead);
347347

348348
Branch branch = repo.Branches[name];
349-
branch.ShouldNotBeNull();
349+
Assert.NotNull(branch);
350350

351351
Branch test = repo.Checkout(branch);
352352
Assert.False(repo.Info.IsHeadDetached);
@@ -507,7 +507,7 @@ public void OnlyOneBranchIsTheHead()
507507
Assert.True(false, string.Format("Both '{0}' and '{1}' appear to be Head.", head.CanonicalName, branch.CanonicalName));
508508
}
509509

510-
head.ShouldNotBeNull();
510+
Assert.NotNull(head);
511511
}
512512
}
513513

@@ -536,7 +536,7 @@ public void CanMoveABranch()
536536
Assert.Equal("br3", newBranch.Name);
537537

538538
Assert.Null(repo.Branches["br2"]);
539-
repo.Branches["br3"].ShouldNotBeNull();
539+
Assert.NotNull(repo.Branches["br3"]);
540540
}
541541
}
542542

@@ -556,18 +556,18 @@ public void CanMoveABranchWhileOverwritingAnExistingOne()
556556
using (var repo = new Repository(path.RepositoryPath))
557557
{
558558
Branch test = repo.Branches["test"];
559-
test.ShouldNotBeNull();
559+
Assert.NotNull(test);
560560

561561
Branch br2 = repo.Branches["br2"];
562-
br2.ShouldNotBeNull();
562+
Assert.NotNull(br2);
563563

564564
Branch newBranch = repo.Branches.Move("br2", "test", true);
565565
Assert.Equal("test", newBranch.Name);
566566

567567
Assert.Null(repo.Branches["br2"]);
568568

569569
Branch newTest = repo.Branches["test"];
570-
newTest.ShouldNotBeNull();
570+
Assert.NotNull(newTest);
571571
Assert.Equal(newBranch, newTest);
572572

573573
Assert.Equal(br2.Tip, newTest.Tip);

LibGit2Sharp.Tests/CommitFixture.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void CanEnumerateCommits()
4545
{
4646
foreach (Commit commit in repo.Commits)
4747
{
48-
commit.ShouldNotBeNull();
48+
Assert.NotNull(commit);
4949
count++;
5050
}
5151
}
@@ -84,7 +84,7 @@ public void CanEnumerateCommitsFromSha()
8484
{
8585
foreach (Commit commit in repo.Commits.QueryBy(new Filter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f" }))
8686
{
87-
commit.ShouldNotBeNull();
87+
Assert.NotNull(commit);
8888
count++;
8989
}
9090
}
@@ -137,7 +137,7 @@ public void CanEnumerateCommitsWithReverseTimeSorting()
137137
{
138138
foreach (Commit commit in repo.Commits.QueryBy(new Filter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f", SortBy = GitSortOptions.Time | GitSortOptions.Reverse }))
139139
{
140-
commit.ShouldNotBeNull();
140+
Assert.NotNull(commit);
141141
Assert.True(commit.Sha.StartsWith(reversedShas[count]));
142142
count++;
143143
}
@@ -153,7 +153,7 @@ public void CanEnumerateCommitsWithReverseTopoSorting()
153153
List<Commit> commits = repo.Commits.QueryBy(new Filter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f", SortBy = GitSortOptions.Time | GitSortOptions.Reverse }).ToList();
154154
foreach (Commit commit in commits)
155155
{
156-
commit.ShouldNotBeNull();
156+
Assert.NotNull(commit);
157157
foreach (Commit p in commit.Parents)
158158
{
159159
Commit parent = commits.Single(x => x.Id == p.Id);
@@ -180,7 +180,7 @@ public void CanEnumerateCommitsWithTimeSorting()
180180
{
181181
foreach (Commit commit in repo.Commits.QueryBy(new Filter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f", SortBy = GitSortOptions.Time }))
182182
{
183-
commit.ShouldNotBeNull();
183+
Assert.NotNull(commit);
184184
Assert.True(commit.Sha.StartsWith(expectedShas[count]));
185185
count++;
186186
}
@@ -196,7 +196,7 @@ public void CanEnumerateCommitsWithTopoSorting()
196196
List<Commit> commits = repo.Commits.QueryBy(new Filter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f", SortBy = GitSortOptions.Topological }).ToList();
197197
foreach (Commit commit in commits)
198198
{
199-
commit.ShouldNotBeNull();
199+
Assert.NotNull(commit);
200200
foreach (Commit p in commit.Parents)
201201
{
202202
Commit parent = commits.Single(x => x.Id == p.Id);
@@ -366,7 +366,7 @@ public void CanReadCommitData()
366366
using (var repo = new Repository(BareTestRepoPath))
367367
{
368368
GitObject obj = repo.Lookup(sha);
369-
obj.ShouldNotBeNull();
369+
Assert.NotNull(obj);
370370
Assert.Equal(typeof(Commit), obj.GetType());
371371

372372
var commit = (Commit)obj;
@@ -375,12 +375,12 @@ public void CanReadCommitData()
375375
Assert.Equal("UTF-8", commit.Encoding);
376376
Assert.Equal(sha, commit.Sha);
377377

378-
commit.Author.ShouldNotBeNull();
378+
Assert.NotNull(commit.Author);
379379
Assert.Equal("Scott Chacon", commit.Author.Name);
380380
Assert.Equal("schacon@gmail.com", commit.Author.Email);
381381
Assert.Equal(1273360386, commit.Author.When.ToSecondsSinceEpoch());
382382

383-
commit.Committer.ShouldNotBeNull();
383+
Assert.NotNull(commit.Committer);
384384
Assert.Equal("Scott Chacon", commit.Committer.Name);
385385
Assert.Equal("schacon@gmail.com", commit.Committer.Email);
386386
Assert.Equal(1273360386, commit.Committer.When.ToSecondsSinceEpoch());
@@ -410,7 +410,7 @@ public void CanDirectlyAccessABlobOfTheCommit()
410410
var commit = repo.Lookup<Commit>("4c062a6");
411411

412412
var blob = commit["1/branch_file.txt"].Target as Blob;
413-
blob.ShouldNotBeNull();
413+
Assert.NotNull(blob);
414414

415415
Assert.Equal("hi\n", blob.ContentAsUtf8());
416416
}
@@ -424,7 +424,7 @@ public void CanDirectlyAccessATreeOfTheCommit()
424424
var commit = repo.Lookup<Commit>("4c062a6");
425425

426426
var tree1 = commit["1"].Target as Tree;
427-
tree1.ShouldNotBeNull();
427+
Assert.NotNull(tree1);
428428
}
429429
}
430430

@@ -609,7 +609,7 @@ public void CanAmendACommitWithMoreThanOneParent()
609609
using (var repo = new Repository(path.RepositoryPath))
610610
{
611611
var mergedCommit = repo.Lookup<Commit>("be3563a");
612-
mergedCommit.ShouldNotBeNull();
612+
Assert.NotNull(mergedCommit);
613613
Assert.Equal(2, mergedCommit.ParentsCount);
614614

615615
repo.Reset(ResetOptions.Soft, mergedCommit.Sha);

LibGit2Sharp.Tests/ConfigurationFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public void CanGetGlobalStringValue()
7474
{
7575
InconclusiveIf(() => !repo.Config.HasGlobalConfig, "No Git global configuration available");
7676

77-
repo.Config.Get<string>("user.name", null).ShouldNotBeNull();
77+
Assert.NotNull(repo.Config.Get<string>("user.name", null));
7878
}
7979
}
8080

@@ -84,7 +84,7 @@ public void CanGetGlobalStringValueWithoutRepo()
8484
using (var config = new Configuration())
8585
{
8686
InconclusiveIf(() => !config.HasGlobalConfig, "No Git global configuration available");
87-
config.Get<string>("user.name", null).ShouldNotBeNull();
87+
Assert.NotNull(config.Get<string>("user.name", null));
8888
}
8989
}
9090

@@ -148,7 +148,7 @@ public void CanSetGlobalStringValue()
148148
InconclusiveIf(() => !repo.Config.HasGlobalConfig, "No Git global configuration available");
149149

150150
var existing = repo.Config.Get<string>("user.name", null);
151-
existing.ShouldNotBeNull();
151+
Assert.NotNull(existing);
152152

153153
try
154154
{
@@ -171,7 +171,7 @@ public void CanSetGlobalStringValueWithoutRepo()
171171
InconclusiveIf(() => !config.HasGlobalConfig, "No Git global configuration available");
172172

173173
var existing = config.Get<string>("user.name", null);
174-
existing.ShouldNotBeNull();
174+
Assert.NotNull(existing);
175175

176176
try
177177
{

LibGit2Sharp.Tests/IndexFixture.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public void CanStageTheRemovalOfAStagedFile()
152152
{
153153
int count = repo.Index.Count;
154154
const string filename = "new_tracked_file.txt";
155-
repo.Index[filename].ShouldNotBeNull();
155+
Assert.NotNull(repo.Index[filename]);
156156

157157
Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename));
158158

@@ -208,15 +208,15 @@ public void CanStageANewFileInAPersistentManner()
208208
Assert.Null(repo.Index[filename]);
209209

210210
repo.Index.Stage(filename);
211-
repo.Index[filename].ShouldNotBeNull();
211+
Assert.NotNull(repo.Index[filename]);
212212
Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename));
213213
Assert.Equal(FileStatus.Added, repo.Index[filename].State);
214214
}
215215

216216
using (var repo = new Repository(path.RepositoryPath))
217217
{
218218
const string filename = "unit_test.txt";
219-
repo.Index[filename].ShouldNotBeNull();
219+
Assert.NotNull(repo.Index[filename]);
220220
Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename));
221221
Assert.Equal(FileStatus.Added, repo.Index[filename].State);
222222
}
@@ -237,7 +237,7 @@ public void CanStageANewFileWithAFullPath()
237237
repo.Index.Stage(fullPath);
238238

239239
Assert.Equal(count + 1, repo.Index.Count);
240-
repo.Index[filename].ShouldNotBeNull();
240+
Assert.NotNull(repo.Index[filename]);
241241
}
242242
}
243243

@@ -259,7 +259,7 @@ public void CanStageANewFileWithARelativePathContainingNativeDirectorySeparatorC
259259
Assert.Equal(count + 1, repo.Index.Count);
260260

261261
const string posixifiedPath = "Project/a_file.txt";
262-
repo.Index[posixifiedPath].ShouldNotBeNull();
262+
Assert.NotNull(repo.Index[posixifiedPath]);
263263
Assert.Equal(file, repo.Index[posixifiedPath].Path);
264264
}
265265
}
@@ -541,8 +541,8 @@ public void PathsOfIndexEntriesAreExpressedInNativeFormat()
541541
IndexEntry ie = index[relFilePath];
542542

543543
// Make sure the IndexEntry has been found
544-
ie.ShouldNotBeNull();
545-
544+
Assert.NotNull(ie);
545+
546546
// Make sure that the (native) relFilePath and ie.Path are equal
547547
Assert.Equal(relFilePath, ie.Path);
548548
}

LibGit2Sharp.Tests/ObjectIdFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public void TryParse(string maybeSha, bool isValidSha)
115115
return;
116116
}
117117

118-
parsedObjectId.ShouldNotBeNull();
118+
Assert.NotNull(parsedObjectId);
119119
Assert.Equal(maybeSha, parsedObjectId.Sha);
120120
Assert.True(maybeSha.StartsWith(parsedObjectId.ToString(3)));
121121
Assert.Equal(maybeSha, parsedObjectId.ToString(42));

0 commit comments

Comments
 (0)