Permalink
Browse files

Replace AssertExtensions.ShouldNotBeNull method by Assert.NotNull

  • Loading branch information...
1 parent e02f76b commit d9c7e7ab91f81231d3f18742a35c37baefbe5389 @yorah yorah committed with nulltoken May 25, 2012
@@ -35,7 +35,7 @@ public void CanLookUpBlob()
using (var repo = new Repository(BareTestRepoPath))
{
var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6");
- blob.ShouldNotBeNull();
+ Assert.NotNull(blob);
}
}
@@ -19,12 +19,12 @@ public void CanCreateBranch(string name)
using (var repo = new Repository(path.RepositoryPath))
{
Branch newBranch = repo.CreateBranch(name, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
- newBranch.ShouldNotBeNull();
+ Assert.NotNull(newBranch);
Assert.Equal(name, newBranch.Name);
Assert.Equal("refs/heads/" + name, newBranch.CanonicalName);
- newBranch.Tip.ShouldNotBeNull();
+ Assert.NotNull(newBranch.Tip);
Assert.Equal("be3563ae3f795b2b4353bcce3a527ad0a4f7f644", newBranch.Tip.Sha);
- repo.Branches.SingleOrDefault(p => p.Name == name).ShouldNotBeNull();
+ Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name == name));
repo.Branches.Delete(newBranch.Name);
}
@@ -51,13 +51,13 @@ public void CanCreateBranchFromImplicitHead()
{
const string name = "unit_test";
Branch newBranch = repo.CreateBranch(name);
- newBranch.ShouldNotBeNull();
+ Assert.NotNull(newBranch);
Assert.Equal(name, newBranch.Name);
Assert.Equal("refs/heads/" + name, newBranch.CanonicalName);
Assert.False(newBranch.IsCurrentRepositoryHead);
- newBranch.Tip.ShouldNotBeNull();
+ Assert.NotNull(newBranch.Tip);
Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
- repo.Branches.SingleOrDefault(p => p.Name == name).ShouldNotBeNull();
+ Assert.NotNull(repo.Branches.SingleOrDefault(p => p.Name == name));
}
}
@@ -69,7 +69,7 @@ public void CanCreateBranchFromExplicitHead()
{
const string name = "unit_test";
Branch newBranch = repo.CreateBranch(name, "HEAD");
- newBranch.ShouldNotBeNull();
+ Assert.NotNull(newBranch);
Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
}
}
@@ -83,7 +83,7 @@ public void CanCreateBranchFromCommit()
const string name = "unit_test";
var commit = repo.Lookup<Commit>("HEAD");
Branch newBranch = repo.CreateBranch(name, commit);
- newBranch.ShouldNotBeNull();
+ Assert.NotNull(newBranch);
Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
}
}
@@ -96,7 +96,7 @@ public void CreatingABranchFromATagPeelsToTheCommit()
{
const string name = "i-peel-tag";
Branch newBranch = repo.CreateBranch(name, "refs/tags/test");
- newBranch.ShouldNotBeNull();
+ Assert.NotNull(newBranch);
Assert.Equal("e90810b8df3e80c413d903f631643c716887138d", newBranch.Tip.Sha);
}
}
@@ -114,7 +114,7 @@ public void CreatingABranchTriggersTheCreationOfADirectReference()
Assert.Equal(commitId, newBranch.Tip.Id);
Reference reference = repo.Refs[newBranch.CanonicalName];
- reference.ShouldNotBeNull();
+ Assert.NotNull(reference);
Assert.IsType(typeof(DirectReference), reference);
}
}
@@ -221,11 +221,11 @@ public void CanLookupABranchByItsCanonicalName()
using (var repo = new Repository(BareTestRepoPath))
{
Branch branch = repo.Branches["refs/heads/br2"];
- branch.ShouldNotBeNull();
+ Assert.NotNull(branch);
Assert.Equal("br2", branch.Name);
Branch branch2 = repo.Branches["refs/heads/br2"];
- branch2.ShouldNotBeNull();
+ Assert.NotNull(branch2);
Assert.Equal("br2", branch2.Name);
Assert.Equal(branch, branch2);
@@ -239,7 +239,7 @@ public void CanLookupLocalBranch()
using (var repo = new Repository(BareTestRepoPath))
{
Branch master = repo.Branches["master"];
- master.ShouldNotBeNull();
+ Assert.NotNull(master);
Assert.False(master.IsRemote);
Assert.Equal("master", master.Name);
Assert.Equal("refs/heads/master", master.CanonicalName);
@@ -256,10 +256,10 @@ public void CanLookupABranchWhichNameIsMadeOfNon7BitsAsciiCharacters()
{
const string name = "Ångström";
Branch newBranch = repo.CreateBranch(name, "be3563a");
- newBranch.ShouldNotBeNull();
+ Assert.NotNull(newBranch);
Branch retrieved = repo.Branches["Ångström"];
- retrieved.ShouldNotBeNull();
+ Assert.NotNull(retrieved);
Assert.Equal(newBranch.Tip, retrieved.Tip);
}
}
@@ -346,7 +346,7 @@ public void CanCheckoutAnExistingBranch(string name)
Assert.True(master.IsCurrentRepositoryHead);
Branch branch = repo.Branches[name];
- branch.ShouldNotBeNull();
+ Assert.NotNull(branch);
Branch test = repo.Checkout(branch);
Assert.False(repo.Info.IsHeadDetached);
@@ -507,7 +507,7 @@ public void OnlyOneBranchIsTheHead()
Assert.True(false, string.Format("Both '{0}' and '{1}' appear to be Head.", head.CanonicalName, branch.CanonicalName));
}
- head.ShouldNotBeNull();
+ Assert.NotNull(head);
}
}
@@ -536,7 +536,7 @@ public void CanMoveABranch()
Assert.Equal("br3", newBranch.Name);
Assert.Null(repo.Branches["br2"]);
- repo.Branches["br3"].ShouldNotBeNull();
+ Assert.NotNull(repo.Branches["br3"]);
}
}
@@ -556,18 +556,18 @@ public void CanMoveABranchWhileOverwritingAnExistingOne()
using (var repo = new Repository(path.RepositoryPath))
{
Branch test = repo.Branches["test"];
- test.ShouldNotBeNull();
+ Assert.NotNull(test);
Branch br2 = repo.Branches["br2"];
- br2.ShouldNotBeNull();
+ Assert.NotNull(br2);
Branch newBranch = repo.Branches.Move("br2", "test", true);
Assert.Equal("test", newBranch.Name);
Assert.Null(repo.Branches["br2"]);
Branch newTest = repo.Branches["test"];
- newTest.ShouldNotBeNull();
+ Assert.NotNull(newTest);
Assert.Equal(newBranch, newTest);
Assert.Equal(br2.Tip, newTest.Tip);
@@ -45,7 +45,7 @@ public void CanEnumerateCommits()
{
foreach (Commit commit in repo.Commits)
{
- commit.ShouldNotBeNull();
+ Assert.NotNull(commit);
count++;
}
}
@@ -84,7 +84,7 @@ public void CanEnumerateCommitsFromSha()
{
foreach (Commit commit in repo.Commits.QueryBy(new Filter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f" }))
{
- commit.ShouldNotBeNull();
+ Assert.NotNull(commit);
count++;
}
}
@@ -137,7 +137,7 @@ public void CanEnumerateCommitsWithReverseTimeSorting()
{
foreach (Commit commit in repo.Commits.QueryBy(new Filter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f", SortBy = GitSortOptions.Time | GitSortOptions.Reverse }))
{
- commit.ShouldNotBeNull();
+ Assert.NotNull(commit);
Assert.True(commit.Sha.StartsWith(reversedShas[count]));
count++;
}
@@ -153,7 +153,7 @@ public void CanEnumerateCommitsWithReverseTopoSorting()
List<Commit> commits = repo.Commits.QueryBy(new Filter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f", SortBy = GitSortOptions.Time | GitSortOptions.Reverse }).ToList();
foreach (Commit commit in commits)
{
- commit.ShouldNotBeNull();
+ Assert.NotNull(commit);
foreach (Commit p in commit.Parents)
{
Commit parent = commits.Single(x => x.Id == p.Id);
@@ -180,7 +180,7 @@ public void CanEnumerateCommitsWithTimeSorting()
{
foreach (Commit commit in repo.Commits.QueryBy(new Filter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f", SortBy = GitSortOptions.Time }))
{
- commit.ShouldNotBeNull();
+ Assert.NotNull(commit);
Assert.True(commit.Sha.StartsWith(expectedShas[count]));
count++;
}
@@ -196,7 +196,7 @@ public void CanEnumerateCommitsWithTopoSorting()
List<Commit> commits = repo.Commits.QueryBy(new Filter { Since = "a4a7dce85cf63874e984719f4fdd239f5145052f", SortBy = GitSortOptions.Topological }).ToList();
foreach (Commit commit in commits)
{
- commit.ShouldNotBeNull();
+ Assert.NotNull(commit);
foreach (Commit p in commit.Parents)
{
Commit parent = commits.Single(x => x.Id == p.Id);
@@ -366,7 +366,7 @@ public void CanReadCommitData()
using (var repo = new Repository(BareTestRepoPath))
{
GitObject obj = repo.Lookup(sha);
- obj.ShouldNotBeNull();
+ Assert.NotNull(obj);
Assert.Equal(typeof(Commit), obj.GetType());
var commit = (Commit)obj;
@@ -375,12 +375,12 @@ public void CanReadCommitData()
Assert.Equal("UTF-8", commit.Encoding);
Assert.Equal(sha, commit.Sha);
- commit.Author.ShouldNotBeNull();
+ Assert.NotNull(commit.Author);
Assert.Equal("Scott Chacon", commit.Author.Name);
Assert.Equal("schacon@gmail.com", commit.Author.Email);
Assert.Equal(1273360386, commit.Author.When.ToSecondsSinceEpoch());
- commit.Committer.ShouldNotBeNull();
+ Assert.NotNull(commit.Committer);
Assert.Equal("Scott Chacon", commit.Committer.Name);
Assert.Equal("schacon@gmail.com", commit.Committer.Email);
Assert.Equal(1273360386, commit.Committer.When.ToSecondsSinceEpoch());
@@ -410,7 +410,7 @@ public void CanDirectlyAccessABlobOfTheCommit()
var commit = repo.Lookup<Commit>("4c062a6");
var blob = commit["1/branch_file.txt"].Target as Blob;
- blob.ShouldNotBeNull();
+ Assert.NotNull(blob);
Assert.Equal("hi\n", blob.ContentAsUtf8());
}
@@ -424,7 +424,7 @@ public void CanDirectlyAccessATreeOfTheCommit()
var commit = repo.Lookup<Commit>("4c062a6");
var tree1 = commit["1"].Target as Tree;
- tree1.ShouldNotBeNull();
+ Assert.NotNull(tree1);
}
}
@@ -609,7 +609,7 @@ public void CanAmendACommitWithMoreThanOneParent()
using (var repo = new Repository(path.RepositoryPath))
{
var mergedCommit = repo.Lookup<Commit>("be3563a");
- mergedCommit.ShouldNotBeNull();
+ Assert.NotNull(mergedCommit);
Assert.Equal(2, mergedCommit.ParentsCount);
repo.Reset(ResetOptions.Soft, mergedCommit.Sha);
@@ -74,7 +74,7 @@ public void CanGetGlobalStringValue()
{
InconclusiveIf(() => !repo.Config.HasGlobalConfig, "No Git global configuration available");
- repo.Config.Get<string>("user.name", null).ShouldNotBeNull();
+ Assert.NotNull(repo.Config.Get<string>("user.name", null));
}
}
@@ -84,7 +84,7 @@ public void CanGetGlobalStringValueWithoutRepo()
using (var config = new Configuration())
{
InconclusiveIf(() => !config.HasGlobalConfig, "No Git global configuration available");
- config.Get<string>("user.name", null).ShouldNotBeNull();
+ Assert.NotNull(config.Get<string>("user.name", null));
}
}
@@ -148,7 +148,7 @@ public void CanSetGlobalStringValue()
InconclusiveIf(() => !repo.Config.HasGlobalConfig, "No Git global configuration available");
var existing = repo.Config.Get<string>("user.name", null);
- existing.ShouldNotBeNull();
+ Assert.NotNull(existing);
try
{
@@ -171,7 +171,7 @@ public void CanSetGlobalStringValueWithoutRepo()
InconclusiveIf(() => !config.HasGlobalConfig, "No Git global configuration available");
var existing = config.Get<string>("user.name", null);
- existing.ShouldNotBeNull();
+ Assert.NotNull(existing);
try
{
@@ -152,7 +152,7 @@ public void CanStageTheRemovalOfAStagedFile()
{
int count = repo.Index.Count;
const string filename = "new_tracked_file.txt";
- repo.Index[filename].ShouldNotBeNull();
+ Assert.NotNull(repo.Index[filename]);
Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename));
@@ -208,15 +208,15 @@ public void CanStageANewFileInAPersistentManner()
Assert.Null(repo.Index[filename]);
repo.Index.Stage(filename);
- repo.Index[filename].ShouldNotBeNull();
+ Assert.NotNull(repo.Index[filename]);
Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename));
Assert.Equal(FileStatus.Added, repo.Index[filename].State);
}
using (var repo = new Repository(path.RepositoryPath))
{
const string filename = "unit_test.txt";
- repo.Index[filename].ShouldNotBeNull();
+ Assert.NotNull(repo.Index[filename]);
Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename));
Assert.Equal(FileStatus.Added, repo.Index[filename].State);
}
@@ -237,7 +237,7 @@ public void CanStageANewFileWithAFullPath()
repo.Index.Stage(fullPath);
Assert.Equal(count + 1, repo.Index.Count);
- repo.Index[filename].ShouldNotBeNull();
+ Assert.NotNull(repo.Index[filename]);
}
}
@@ -259,7 +259,7 @@ public void CanStageANewFileWithARelativePathContainingNativeDirectorySeparatorC
Assert.Equal(count + 1, repo.Index.Count);
const string posixifiedPath = "Project/a_file.txt";
- repo.Index[posixifiedPath].ShouldNotBeNull();
+ Assert.NotNull(repo.Index[posixifiedPath]);
Assert.Equal(file, repo.Index[posixifiedPath].Path);
}
}
@@ -541,8 +541,8 @@ public void PathsOfIndexEntriesAreExpressedInNativeFormat()
IndexEntry ie = index[relFilePath];
// Make sure the IndexEntry has been found
- ie.ShouldNotBeNull();
-
+ Assert.NotNull(ie);
+
// Make sure that the (native) relFilePath and ie.Path are equal
Assert.Equal(relFilePath, ie.Path);
}
@@ -115,7 +115,7 @@ public void TryParse(string maybeSha, bool isValidSha)
return;
}
- parsedObjectId.ShouldNotBeNull();
+ Assert.NotNull(parsedObjectId);
Assert.Equal(maybeSha, parsedObjectId.Sha);
Assert.True(maybeSha.StartsWith(parsedObjectId.ToString(3)));
Assert.Equal(maybeSha, parsedObjectId.ToString(42));
Oops, something went wrong.

0 comments on commit d9c7e7a

Please sign in to comment.