Skip to content
Browse files

Replace AssertExtensions.ShouldEqual method by Assert.Equal

  • Loading branch information...
1 parent 9bb8408 commit b9bd9c852eb3751d7a7013d7eb8493f1ba070ced @yorah yorah committed with nulltoken May 25, 2012
View
14 LibGit2Sharp.Tests/BlobFixture.cs
@@ -15,7 +15,7 @@ public void CanGetBlobAsUtf8()
var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6");
string text = blob.ContentAsUtf8();
- text.ShouldEqual("hey there\n");
+ Assert.Equal("hey there\n", text);
}
}
@@ -25,7 +25,7 @@ public void CanGetBlobSize()
using (var repo = new Repository(BareTestRepoPath))
{
var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6");
- blob.Size.ShouldEqual(10);
+ Assert.Equal(10, blob.Size);
}
}
@@ -46,10 +46,10 @@ public void CanReadBlobContent()
{
var blob = repo.Lookup<Blob>("a8233120f6ad708f843d861ce2b7228ec4e3dec6");
byte[] bytes = blob.Content;
- bytes.Length.ShouldEqual(10);
+ Assert.Equal(10, bytes.Length);
string content = Encoding.UTF8.GetString(bytes);
- content.ShouldEqual("hey there\n");
+ Assert.Equal("hey there\n", content);
}
}
@@ -63,7 +63,7 @@ public void CanReadBlobStream()
using (var tr = new StreamReader(blob.ContentStream, Encoding.UTF8))
{
string content = tr.ReadToEnd();
- content.ShouldEqual("hey there\n");
+ Assert.Equal("hey there\n", content);
}
}
}
@@ -97,7 +97,7 @@ public void CanStageAFileGeneratedFromABlobContentStream()
repo.Index.Stage("small.txt");
IndexEntry entry = repo.Index["small.txt"];
- entry.Id.Sha.ShouldEqual("baae1fb3760a73481ced1fa03dc15614142c19ef");
+ Assert.Equal("baae1fb3760a73481ced1fa03dc15614142c19ef", entry.Id.Sha);
var blob = repo.Lookup<Blob>(entry.Id.Sha);
@@ -110,7 +110,7 @@ public void CanStageAFileGeneratedFromABlobContentStream()
repo.Index.Stage("small.fromblob.txt");
IndexEntry newentry = repo.Index["small.fromblob.txt"];
- newentry.Id.Sha.ShouldEqual("baae1fb3760a73481ced1fa03dc15614142c19ef");
+ Assert.Equal("baae1fb3760a73481ced1fa03dc15614142c19ef", newentry.Id.Sha);
}
}
}
View
80 LibGit2Sharp.Tests/BranchFixture.cs
@@ -20,10 +20,10 @@ public void CanCreateBranch(string name)
{
Branch newBranch = repo.CreateBranch(name, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
newBranch.ShouldNotBeNull();
- newBranch.Name.ShouldEqual(name);
- newBranch.CanonicalName.ShouldEqual("refs/heads/" + name);
+ Assert.Equal(name, newBranch.Name);
+ Assert.Equal("refs/heads/" + name, newBranch.CanonicalName);
newBranch.Tip.ShouldNotBeNull();
- newBranch.Tip.Sha.ShouldEqual("be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
+ Assert.Equal("be3563ae3f795b2b4353bcce3a527ad0a4f7f644", newBranch.Tip.Sha);
repo.Branches.SingleOrDefault(p => p.Name == name).ShouldNotBeNull();
repo.Branches.Delete(newBranch.Name);
@@ -38,8 +38,8 @@ public void CanCreateBranchUsingAbbreviatedSha()
{
const string name = "unit_test";
Branch newBranch = repo.CreateBranch(name, "be3563a");
- newBranch.CanonicalName.ShouldEqual("refs/heads/" + name);
- newBranch.Tip.Sha.ShouldEqual("be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
+ Assert.Equal("refs/heads/" + name, newBranch.CanonicalName);
+ Assert.Equal("be3563ae3f795b2b4353bcce3a527ad0a4f7f644", newBranch.Tip.Sha);
}
}
@@ -52,11 +52,11 @@ public void CanCreateBranchFromImplicitHead()
const string name = "unit_test";
Branch newBranch = repo.CreateBranch(name);
newBranch.ShouldNotBeNull();
- newBranch.Name.ShouldEqual(name);
- newBranch.CanonicalName.ShouldEqual("refs/heads/" + name);
+ Assert.Equal(name, newBranch.Name);
+ Assert.Equal("refs/heads/" + name, newBranch.CanonicalName);
Assert.False(newBranch.IsCurrentRepositoryHead);
newBranch.Tip.ShouldNotBeNull();
- newBranch.Tip.Sha.ShouldEqual("4c062a6361ae6959e06292c1fa5e2822d9c96345");
+ Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
repo.Branches.SingleOrDefault(p => p.Name == name).ShouldNotBeNull();
}
}
@@ -70,7 +70,7 @@ public void CanCreateBranchFromExplicitHead()
const string name = "unit_test";
Branch newBranch = repo.CreateBranch(name, "HEAD");
newBranch.ShouldNotBeNull();
- newBranch.Tip.Sha.ShouldEqual("4c062a6361ae6959e06292c1fa5e2822d9c96345");
+ Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
}
}
@@ -84,7 +84,7 @@ public void CanCreateBranchFromCommit()
var commit = repo.Lookup<Commit>("HEAD");
Branch newBranch = repo.CreateBranch(name, commit);
newBranch.ShouldNotBeNull();
- newBranch.Tip.Sha.ShouldEqual("4c062a6361ae6959e06292c1fa5e2822d9c96345");
+ Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newBranch.Tip.Sha);
}
}
@@ -97,7 +97,7 @@ public void CreatingABranchFromATagPeelsToTheCommit()
const string name = "i-peel-tag";
Branch newBranch = repo.CreateBranch(name, "refs/tags/test");
newBranch.ShouldNotBeNull();
- newBranch.Tip.Sha.ShouldEqual("e90810b8df3e80c413d903f631643c716887138d");
+ Assert.Equal("e90810b8df3e80c413d903f631643c716887138d", newBranch.Tip.Sha);
}
}
@@ -111,7 +111,7 @@ public void CreatingABranchTriggersTheCreationOfADirectReference()
Assert.False(newBranch.IsCurrentRepositoryHead);
ObjectId commitId = repo.Head.Tip.Id;
- newBranch.Tip.Id.ShouldEqual(commitId);
+ Assert.Equal(commitId, newBranch.Tip.Id);
Reference reference = repo.Refs[newBranch.CanonicalName];
reference.ShouldNotBeNull();
@@ -179,7 +179,7 @@ public void CanListAllBranches()
{
Assert.Equal(expectedBranches, repo.Branches.Select(b => b.Name).ToArray());
- repo.Branches.Count().ShouldEqual(5);
+ Assert.Equal(5, repo.Branches.Count());
}
}
@@ -222,13 +222,13 @@ public void CanLookupABranchByItsCanonicalName()
{
Branch branch = repo.Branches["refs/heads/br2"];
branch.ShouldNotBeNull();
- branch.Name.ShouldEqual("br2");
+ Assert.Equal("br2", branch.Name);
Branch branch2 = repo.Branches["refs/heads/br2"];
branch2.ShouldNotBeNull();
- branch2.Name.ShouldEqual("br2");
+ Assert.Equal("br2", branch2.Name);
- branch2.ShouldEqual(branch);
+ Assert.Equal(branch, branch2);
(branch2 == branch).ShouldBeTrue();
}
}
@@ -241,10 +241,10 @@ public void CanLookupLocalBranch()
Branch master = repo.Branches["master"];
master.ShouldNotBeNull();
Assert.False(master.IsRemote);
- master.Name.ShouldEqual("master");
- master.CanonicalName.ShouldEqual("refs/heads/master");
+ Assert.Equal("master", master.Name);
+ Assert.Equal("refs/heads/master", master.CanonicalName);
master.IsCurrentRepositoryHead.ShouldBeTrue();
- master.Tip.Sha.ShouldEqual("4c062a6361ae6959e06292c1fa5e2822d9c96345");
+ Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", master.Tip.Sha);
}
}
@@ -260,7 +260,7 @@ public void CanLookupABranchWhichNameIsMadeOfNon7BitsAsciiCharacters()
Branch retrieved = repo.Branches["Ångström"];
retrieved.ShouldNotBeNull();
- retrieved.Tip.ShouldEqual(newBranch.Tip);
+ Assert.Equal(newBranch.Tip, retrieved.Tip);
}
}
@@ -283,8 +283,8 @@ public void TrackingInformationIsEmptyForNonTrackingBranch()
Branch branch = repo.Branches["test"];
Assert.False(branch.IsTracking);
branch.TrackedBranch.ShouldBeNull();
- branch.AheadBy.ShouldEqual(0);
- branch.BehindBy.ShouldEqual(0);
+ Assert.Equal(0, branch.AheadBy);
+ Assert.Equal(0, branch.BehindBy);
}
}
@@ -295,9 +295,9 @@ public void CanGetTrackingInformationForTrackingBranch()
{
Branch master = repo.Branches["master"];
master.IsTracking.ShouldBeTrue();
- master.TrackedBranch.ShouldEqual(repo.Branches["refs/remotes/origin/master"]);
- master.AheadBy.ShouldEqual(2);
- master.BehindBy.ShouldEqual(2);
+ Assert.Equal(repo.Branches["refs/remotes/origin/master"], master.TrackedBranch);
+ Assert.Equal(2, master.AheadBy);
+ Assert.Equal(2, master.BehindBy);
}
}
@@ -308,9 +308,9 @@ public void CanGetTrackingInformationForLocalTrackingBranch()
{
var branch = repo.Branches["track-local"];
branch.IsTracking.ShouldBeTrue();
- branch.TrackedBranch.ShouldEqual(repo.Branches["master"]);
- branch.AheadBy.ShouldEqual(2);
- branch.BehindBy.ShouldEqual(2);
+ Assert.Equal(repo.Branches["master"], branch.TrackedBranch);
+ Assert.Equal(2, branch.AheadBy);
+ Assert.Equal(2, branch.BehindBy);
}
}
@@ -320,7 +320,7 @@ public void CanWalkCommitsFromAnotherBranch()
using (var repo = new Repository(BareTestRepoPath))
{
Branch master = repo.Branches["test"];
- master.Commits.Count().ShouldEqual(2);
+ Assert.Equal(2, master.Commits.Count());
}
}
@@ -330,7 +330,7 @@ public void CanWalkCommitsFromBranch()
using (var repo = new Repository(BareTestRepoPath))
{
Branch master = repo.Branches["master"];
- master.Commits.Count().ShouldEqual(7);
+ Assert.Equal(7, master.Commits.Count());
}
}
@@ -353,7 +353,7 @@ public void CanCheckoutAnExistingBranch(string name)
Assert.False(test.IsRemote);
test.IsCurrentRepositoryHead.ShouldBeTrue();
- test.ShouldEqual(repo.Head);
+ Assert.Equal(repo.Head, test);
Assert.False(master.IsCurrentRepositoryHead);
}
@@ -375,7 +375,7 @@ public void CanCheckoutAnExistingBranchByName(string name)
Assert.False(test.IsRemote);
test.IsCurrentRepositoryHead.ShouldBeTrue();
- test.ShouldEqual(repo.Head);
+ Assert.Equal(repo.Head, test);
Assert.False(master.IsCurrentRepositoryHead);
}
@@ -397,11 +397,11 @@ public void CanCheckoutAnArbitraryCommit(string commitPointer)
repo.Info.IsHeadDetached.ShouldBeTrue();
Assert.False(detachedHead.IsRemote);
- detachedHead.CanonicalName.ShouldEqual(detachedHead.Name);
- detachedHead.CanonicalName.ShouldEqual("(no branch)");
- detachedHead.Tip.Sha.ShouldEqual(repo.Lookup(commitPointer).Sha);
+ Assert.Equal(detachedHead.Name, detachedHead.CanonicalName);
+ Assert.Equal("(no branch)", detachedHead.CanonicalName);
+ Assert.Equal(repo.Lookup(commitPointer).Sha, detachedHead.Tip.Sha);
- detachedHead.ShouldEqual(repo.Head);
+ Assert.Equal(repo.Head, detachedHead);
Assert.False(master.IsCurrentRepositoryHead);
detachedHead.IsCurrentRepositoryHead.ShouldBeTrue();
@@ -533,7 +533,7 @@ public void CanMoveABranch()
repo.Branches["br3"].ShouldBeNull();
Branch newBranch = repo.Branches.Move("br2", "br3");
- newBranch.Name.ShouldEqual("br3");
+ Assert.Equal("br3", newBranch.Name);
repo.Branches["br2"].ShouldBeNull();
repo.Branches["br3"].ShouldNotBeNull();
@@ -562,15 +562,15 @@ public void CanMoveABranchWhileOverwritingAnExistingOne()
br2.ShouldNotBeNull();
Branch newBranch = repo.Branches.Move("br2", "test", true);
- newBranch.Name.ShouldEqual("test");
+ Assert.Equal("test", newBranch.Name);
repo.Branches["br2"].ShouldBeNull();
Branch newTest = repo.Branches["test"];
newTest.ShouldNotBeNull();
- newTest.ShouldEqual(newBranch);
+ Assert.Equal(newBranch, newTest);
- newTest.Tip.ShouldEqual(br2.Tip);
+ Assert.Equal(br2.Tip, newTest.Tip);
}
}
}
View
6 LibGit2Sharp.Tests/CommitAncestorFixture.cs
@@ -39,7 +39,7 @@ public void CanFindCommonAncestorForTwoCommits()
Commit ancestor = repo.Commits.FindCommonAncestor(first, second);
Assert.NotNull(ancestor);
- ancestor.Id.Sha.ShouldEqual("5b5b025afb0b4c913b4c338a42934a3863bf3644");
+ Assert.Equal("5b5b025afb0b4c913b4c338a42934a3863bf3644", ancestor.Id.Sha);
}
}
@@ -54,7 +54,7 @@ public void CanFindCommonAncestorForTwoCommitsAsEnumerable()
Commit ancestor = repo.Commits.FindCommonAncestor(new[] { first, second });
Assert.NotNull(ancestor);
- ancestor.Id.Sha.ShouldEqual("5b5b025afb0b4c913b4c338a42934a3863bf3644");
+ Assert.Equal("5b5b025afb0b4c913b4c338a42934a3863bf3644", ancestor.Id.Sha);
}
}
@@ -71,7 +71,7 @@ public void CanFindCommonAncestorForSeveralCommits()
Commit ancestor = repo.Commits.FindCommonAncestor(new[] { first, second, third, fourth });
Assert.NotNull(ancestor);
- ancestor.Id.Sha.ShouldEqual("5b5b025afb0b4c913b4c338a42934a3863bf3644");
+ Assert.Equal("5b5b025afb0b4c913b4c338a42934a3863bf3644", ancestor.Id.Sha);
}
}
View
92 LibGit2Sharp.Tests/CommitFixture.cs
@@ -18,7 +18,7 @@ public void CanCountCommits()
{
using (var repo = new Repository(BareTestRepoPath))
{
- repo.Commits.Count().ShouldEqual(7);
+ Assert.Equal(7, repo.Commits.Count());
}
}
@@ -28,12 +28,12 @@ public void CanCorrectlyCountCommitsWhenSwitchingToAnotherBranch()
using (var repo = new Repository(BareTestRepoPath))
{
repo.Checkout("test");
- repo.Commits.Count().ShouldEqual(2);
- repo.Commits.First().Id.Sha.ShouldEqual("e90810b8df3e80c413d903f631643c716887138d");
+ Assert.Equal(2, repo.Commits.Count());
+ Assert.Equal("e90810b8df3e80c413d903f631643c716887138d", repo.Commits.First().Id.Sha);
repo.Checkout("master");
- repo.Commits.Count().ShouldEqual(7);
- repo.Commits.First().Id.Sha.ShouldEqual("4c062a6361ae6959e06292c1fa5e2822d9c96345");
+ Assert.Equal(7, repo.Commits.Count());
+ Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", repo.Commits.First().Id.Sha);
}
}
@@ -49,7 +49,7 @@ public void CanEnumerateCommits()
count++;
}
}
- count.ShouldEqual(7);
+ Assert.Equal(7, count);
}
[Fact]
@@ -63,7 +63,7 @@ public void CanEnumerateCommitsInDetachedHeadState()
repo.Refs.Create("HEAD", parentOfHead.Sha, true);
Assert.Equal(true, repo.Info.IsHeadDetached);
- repo.Commits.Count().ShouldEqual(6);
+ Assert.Equal(6, repo.Commits.Count());
}
}
@@ -72,7 +72,7 @@ public void DefaultOrderingWhenEnumeratingCommitsIsTimeBased()
{
using (var repo = new Repository(BareTestRepoPath))
{
- repo.Commits.SortedBy.ShouldEqual(GitSortOptions.Time);
+ Assert.Equal(GitSortOptions.Time, repo.Commits.SortedBy);
}
}
@@ -88,7 +88,7 @@ public void CanEnumerateCommitsFromSha()
count++;
}
}
- count.ShouldEqual(6);
+ Assert.Equal(6, count);
}
[Fact]
@@ -142,7 +142,7 @@ public void CanEnumerateCommitsWithReverseTimeSorting()
count++;
}
}
- count.ShouldEqual(6);
+ Assert.Equal(6, count);
}
[Fact]
@@ -168,7 +168,7 @@ public void CanGetParentsCount()
{
using (var repo = new Repository(BareTestRepoPath))
{
- repo.Commits.First().ParentsCount.ShouldEqual(1);
+ Assert.Equal(1, repo.Commits.First().ParentsCount);
}
}
@@ -185,7 +185,7 @@ public void CanEnumerateCommitsWithTimeSorting()
count++;
}
}
- count.ShouldEqual(6);
+ Assert.Equal(6, count);
}
[Fact]
@@ -354,9 +354,9 @@ public void CanLookupCommitGeneric()
using (var repo = new Repository(BareTestRepoPath))
{
var commit = repo.Lookup<Commit>(sha);
- commit.Message.ShouldEqual("testing\n");
- commit.MessageShort.ShouldEqual("testing");
- commit.Sha.ShouldEqual(sha);
+ Assert.Equal("testing\n", commit.Message);
+ Assert.Equal("testing", commit.MessageShort);
+ Assert.Equal(sha, commit.Sha);
}
}
@@ -367,27 +367,27 @@ public void CanReadCommitData()
{
GitObject obj = repo.Lookup(sha);
obj.ShouldNotBeNull();
- obj.GetType().ShouldEqual(typeof(Commit));
+ Assert.Equal(typeof(Commit), obj.GetType());
var commit = (Commit)obj;
- commit.Message.ShouldEqual("testing\n");
- commit.MessageShort.ShouldEqual("testing");
- commit.Encoding.ShouldEqual("UTF-8");
- commit.Sha.ShouldEqual(sha);
+ Assert.Equal("testing\n", commit.Message);
+ Assert.Equal("testing", commit.MessageShort);
+ Assert.Equal("UTF-8", commit.Encoding);
+ Assert.Equal(sha, commit.Sha);
commit.Author.ShouldNotBeNull();
- commit.Author.Name.ShouldEqual("Scott Chacon");
- commit.Author.Email.ShouldEqual("schacon@gmail.com");
- commit.Author.When.ToSecondsSinceEpoch().ShouldEqual(1273360386);
+ 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();
- commit.Committer.Name.ShouldEqual("Scott Chacon");
- commit.Committer.Email.ShouldEqual("schacon@gmail.com");
- commit.Committer.When.ToSecondsSinceEpoch().ShouldEqual(1273360386);
+ Assert.Equal("Scott Chacon", commit.Committer.Name);
+ Assert.Equal("schacon@gmail.com", commit.Committer.Email);
+ Assert.Equal(1273360386, commit.Committer.When.ToSecondsSinceEpoch());
- commit.Tree.Sha.ShouldEqual("181037049a54a1eb5fab404658a3a250b44335d7");
+ Assert.Equal("181037049a54a1eb5fab404658a3a250b44335d7", commit.Tree.Sha);
- commit.ParentsCount.ShouldEqual(0);
+ Assert.Equal(0, commit.ParentsCount);
}
}
@@ -397,8 +397,8 @@ public void CanReadCommitWithMultipleParents()
using (var repo = new Repository(BareTestRepoPath))
{
var commit = repo.Lookup<Commit>("a4a7dce85cf63874e984719f4fdd239f5145052f");
- commit.Parents.Count().ShouldEqual(2);
- commit.ParentsCount.ShouldEqual(2);
+ Assert.Equal(2, commit.Parents.Count());
+ Assert.Equal(2, commit.ParentsCount);
}
}
@@ -412,7 +412,7 @@ public void CanDirectlyAccessABlobOfTheCommit()
var blob = commit["1/branch_file.txt"].Target as Blob;
blob.ShouldNotBeNull();
- blob.ContentAsUtf8().ShouldEqual("hi\n");
+ Assert.Equal("hi\n", blob.ContentAsUtf8());
}
}
@@ -503,7 +503,7 @@ public void CanCommitALittleBit()
AssertBlobContent(repo.Head[relativeFilepath], "nulltoken\n");
AssertBlobContent(commit[relativeFilepath], "nulltoken\n");
- commit.ParentsCount.ShouldEqual(0);
+ Assert.Equal(0, commit.ParentsCount);
Assert.False(repo.Info.IsEmpty);
File.WriteAllText(filePath, "nulltoken commits!\n");
@@ -515,8 +515,8 @@ public void CanCommitALittleBit()
AssertBlobContent(repo.Head[relativeFilepath], "nulltoken commits!\n");
AssertBlobContent(commit2[relativeFilepath], "nulltoken commits!\n");
- commit2.ParentsCount.ShouldEqual(1);
- commit2.Parents.First().Id.ShouldEqual(commit.Id);
+ Assert.Equal(1, commit2.ParentsCount);
+ Assert.Equal(commit.Id, commit2.Parents.First().Id);
Branch firstCommitBranch = repo.CreateBranch("davidfowl-rules", commit);
repo.Checkout(firstCommitBranch);
@@ -531,17 +531,17 @@ public void CanCommitALittleBit()
AssertBlobContent(repo.Head[relativeFilepath], "davidfowl commits!\n");
AssertBlobContent(commit3[relativeFilepath], "davidfowl commits!\n");
- commit3.ParentsCount.ShouldEqual(1);
- commit3.Parents.First().Id.ShouldEqual(commit.Id);
+ Assert.Equal(1, commit3.ParentsCount);
+ Assert.Equal(commit.Id, commit3.Parents.First().Id);
AssertBlobContent(firstCommitBranch[relativeFilepath], "nulltoken\n");
}
}
private static void AssertBlobContent(TreeEntry entry, string expectedContent)
{
- entry.Type.ShouldEqual(GitObjectType.Blob);
- ((Blob)(entry.Target)).ContentAsUtf8().ShouldEqual(expectedContent);
+ Assert.Equal(GitObjectType.Blob, entry.Type);
+ Assert.Equal(expectedContent, ((Blob)(entry.Target)).ContentAsUtf8());
}
private static void CommitToANewRepository(string path)
@@ -569,12 +569,12 @@ public void CanGeneratePredictableObjectShas()
using (var repo = new Repository(scd.DirectoryPath))
{
Commit commit = repo.Commits.Single();
- commit.Sha.ShouldEqual("1fe3126578fc4eca68c193e4a3a0a14a0704624d");
+ Assert.Equal("1fe3126578fc4eca68c193e4a3a0a14a0704624d", commit.Sha);
Tree tree = commit.Tree;
- tree.Sha.ShouldEqual("2b297e643c551e76cfa1f93810c50811382f9117");
+ Assert.Equal("2b297e643c551e76cfa1f93810c50811382f9117", tree.Sha);
Blob blob = tree.Blobs.Single();
- blob.Sha.ShouldEqual("9daeafb9864cf43055ae93beb0afd6c7d144bfa4");
+ Assert.Equal("9daeafb9864cf43055ae93beb0afd6c7d144bfa4", blob.Sha);
}
}
@@ -587,16 +587,16 @@ public void CanAmendARootCommit()
using (var repo = new Repository(scd.DirectoryPath))
{
- repo.Head.Commits.Count().ShouldEqual(1);
+ Assert.Equal(1, repo.Head.Commits.Count());
Commit originalCommit = repo.Head.Tip;
- originalCommit.ParentsCount.ShouldEqual(0);
+ Assert.Equal(0, originalCommit.ParentsCount);
CreateAndStageANewFile(repo);
Commit amendedCommit = repo.Commit("I'm rewriting the history!", DummySignature, DummySignature, true);
- repo.Head.Commits.Count().ShouldEqual(1);
+ Assert.Equal(1, repo.Head.Commits.Count());
AssertCommitHasBeenAmended(repo, amendedCommit, originalCommit);
}
@@ -610,7 +610,7 @@ public void CanAmendACommitWithMoreThanOneParent()
{
var mergedCommit = repo.Lookup<Commit>("be3563a");
mergedCommit.ShouldNotBeNull();
- mergedCommit.ParentsCount.ShouldEqual(2);
+ Assert.Equal(2, mergedCommit.ParentsCount);
repo.Reset(ResetOptions.Soft, mergedCommit.Sha);
@@ -634,7 +634,7 @@ private static void CreateAndStageANewFile(Repository repo)
private void AssertCommitHasBeenAmended(Repository repo, Commit amendedCommit, Commit originalCommit)
{
Commit headCommit = repo.Head.Tip;
- headCommit.ShouldEqual(amendedCommit);
+ Assert.Equal(amendedCommit, headCommit);
amendedCommit.Sha.ShouldNotEqual(originalCommit.Sha);
Assert.Equal(originalCommit.Parents, amendedCommit.Parents);
View
14 LibGit2Sharp.Tests/ConfigurationFixture.cs
@@ -242,14 +242,14 @@ public void CanSetAndReadUnicodeStringValue()
AssertValueInLocalConfigFile(path.RepositoryPath, "stringsetting = Juliën$");
string val = repo.Config.Get("unittests.stringsetting", "");
- val.ShouldEqual("Juliën");
+ Assert.Equal("Juliën", val);
}
// Make sure the change is permanent
using (var repo = new Repository(path.RepositoryPath))
{
string val = repo.Config.Get("unittests.stringsetting", "");
- val.ShouldEqual("Juliën");
+ Assert.Equal("Juliën", val);
}
}
@@ -269,12 +269,12 @@ public void ReadingValueThatDoesntExistReturnsDefault()
using (var repo = new Repository(StandardTestRepoPath))
{
repo.Config.Get<string>("unittests.ghostsetting", null).ShouldBeNull();
- repo.Config.Get<int>("unittests.ghostsetting", 0).ShouldEqual(0);
- repo.Config.Get<long>("unittests.ghostsetting", 0L).ShouldEqual(0L);
+ Assert.Equal(0, repo.Config.Get<int>("unittests.ghostsetting", 0));
+ Assert.Equal(0L, repo.Config.Get<long>("unittests.ghostsetting", 0L));
Assert.False(repo.Config.Get<bool>("unittests.ghostsetting", false));
- repo.Config.Get("unittests.ghostsetting", "42").ShouldEqual("42");
- repo.Config.Get("unittests.ghostsetting", 42).ShouldEqual(42);
- repo.Config.Get("unittests.ghostsetting", 42L).ShouldEqual(42L);
+ Assert.Equal("42", repo.Config.Get("unittests.ghostsetting", "42"));
+ Assert.Equal(42, repo.Config.Get("unittests.ghostsetting", 42));
+ Assert.Equal(42L, repo.Config.Get("unittests.ghostsetting", 42L));
repo.Config.Get("unittests.ghostsetting", true).ShouldBeTrue();
}
}
View
124 LibGit2Sharp.Tests/IndexFixture.cs
@@ -31,7 +31,7 @@ public void CanCountEntriesInIndex()
{
using (var repo = new Repository(StandardTestRepoPath))
{
- repo.Index.Count.ShouldEqual(expectedEntries.Count());
+ Assert.Equal(expectedEntries.Count(), repo.Index.Count);
}
}
@@ -50,15 +50,15 @@ public void CanFetchAnIndexEntryByItsName()
using (var repo = new Repository(StandardTestRepoPath))
{
IndexEntry entry = repo.Index["README"];
- entry.Path.ShouldEqual("README");
+ Assert.Equal("README", entry.Path);
// Expressed in Posix format...
IndexEntry entryWithPath = repo.Index["1/branch_file.txt"];
- entryWithPath.Path.ShouldEqual(subBranchFile);
+ Assert.Equal(subBranchFile, entryWithPath.Path);
//...or in native format
IndexEntry entryWithPath2 = repo.Index[subBranchFile];
- entryWithPath2.ShouldEqual(entryWithPath);
+ Assert.Equal(entryWithPath, entryWithPath2);
}
}
@@ -95,14 +95,14 @@ public void CanStage(string relativePath, FileStatus currentStatus, bool doesCur
using (var repo = new Repository(path.RepositoryPath))
{
int count = repo.Index.Count;
- (repo.Index[relativePath] != null).ShouldEqual(doesCurrentlyExistInTheIndex);
- repo.Index.RetrieveStatus(relativePath).ShouldEqual(currentStatus);
+ Assert.Equal(doesCurrentlyExistInTheIndex, (repo.Index[relativePath] != null));
+ Assert.Equal(currentStatus, repo.Index.RetrieveStatus(relativePath));
repo.Index.Stage(relativePath);
- repo.Index.Count.ShouldEqual(count + expectedIndexCountVariation);
- (repo.Index[relativePath] != null).ShouldEqual(doesExistInTheIndexOnceStaged);
- repo.Index.RetrieveStatus(relativePath).ShouldEqual(expectedStatusOnceStaged);
+ Assert.Equal(count + expectedIndexCountVariation, repo.Index.Count);
+ Assert.Equal(doesExistInTheIndexOnceStaged, (repo.Index[relativePath] != null));
+ Assert.Equal(expectedStatusOnceStaged, repo.Index.RetrieveStatus(relativePath));
}
}
@@ -116,17 +116,17 @@ public void CanStageTheUpdationOfAStagedFile()
const string filename = "new_tracked_file.txt";
IndexEntry blob = repo.Index[filename];
- repo.Index.RetrieveStatus(filename).ShouldEqual(FileStatus.Added);
+ Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename));
File.WriteAllText(Path.Combine(repo.Info.WorkingDirectory, filename), "brand new content");
- repo.Index.RetrieveStatus(filename).ShouldEqual(FileStatus.Added | FileStatus.Modified);
+ Assert.Equal(FileStatus.Added | FileStatus.Modified, repo.Index.RetrieveStatus(filename));
repo.Index.Stage(filename);
IndexEntry newBlob = repo.Index[filename];
- repo.Index.Count.ShouldEqual(count);
+ Assert.Equal(count, repo.Index.Count);
blob.Id.ShouldNotEqual(newBlob.Id);
- repo.Index.RetrieveStatus(filename).ShouldEqual(FileStatus.Added);
+ Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename));
}
}
@@ -138,7 +138,7 @@ public void StagingAnUnknownFileThrows(string relativePath, FileStatus status)
using (var repo = new Repository(StandardTestRepoPath))
{
repo.Index[relativePath].ShouldBeNull();
- repo.Index.RetrieveStatus(relativePath).ShouldEqual(status);
+ Assert.Equal(status, repo.Index.RetrieveStatus(relativePath));
Assert.Throws<LibGit2Exception>(() => repo.Index.Stage(relativePath));
}
@@ -154,16 +154,16 @@ public void CanStageTheRemovalOfAStagedFile()
const string filename = "new_tracked_file.txt";
repo.Index[filename].ShouldNotBeNull();
- repo.Index.RetrieveStatus(filename).ShouldEqual(FileStatus.Added);
+ Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename));
File.Delete(Path.Combine(repo.Info.WorkingDirectory, filename));
- repo.Index.RetrieveStatus(filename).ShouldEqual(FileStatus.Added | FileStatus.Missing);
+ Assert.Equal(FileStatus.Added | FileStatus.Missing, repo.Index.RetrieveStatus(filename));
repo.Index.Stage(filename);
repo.Index[filename].ShouldBeNull();
- repo.Index.Count.ShouldEqual(count - 1);
- repo.Index.RetrieveStatus(filename).ShouldEqual(FileStatus.Nonexistent);
+ Assert.Equal(count - 1, repo.Index.Count);
+ Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus(filename));
}
}
@@ -184,12 +184,12 @@ public void StagingANewVersionOfAFileThenUnstagingItRevertsTheBlobToTheVersionOf
File.AppendAllText(fullpath, "Is there there anybody out there?");
repo.Index.Stage(filename);
- repo.Index.Count.ShouldEqual(count);
+ Assert.Equal(count, repo.Index.Count);
repo.Index[posixifiedFileName].Id.ShouldNotEqual((blobId));
repo.Index.Unstage(posixifiedFileName);
- repo.Index.Count.ShouldEqual(count);
- repo.Index[posixifiedFileName].Id.ShouldEqual((blobId));
+ Assert.Equal(count, repo.Index.Count);
+ Assert.Equal(blobId, repo.Index[posixifiedFileName].Id);
}
}
@@ -200,25 +200,25 @@ public void CanStageANewFileInAPersistentManner()
using (var repo = new Repository(path.RepositoryPath))
{
const string filename = "unit_test.txt";
- repo.Index.RetrieveStatus(filename).ShouldEqual(FileStatus.Nonexistent);
+ Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus(filename));
repo.Index[filename].ShouldBeNull();
File.WriteAllText(Path.Combine(repo.Info.WorkingDirectory, filename), "some contents");
- repo.Index.RetrieveStatus(filename).ShouldEqual(FileStatus.Untracked);
+ Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(filename));
repo.Index[filename].ShouldBeNull();
repo.Index.Stage(filename);
repo.Index[filename].ShouldNotBeNull();
- repo.Index.RetrieveStatus(filename).ShouldEqual(FileStatus.Added);
- repo.Index[filename].State.ShouldEqual(FileStatus.Added);
+ 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();
- repo.Index.RetrieveStatus(filename).ShouldEqual(FileStatus.Added);
- repo.Index[filename].State.ShouldEqual(FileStatus.Added);
+ Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(filename));
+ Assert.Equal(FileStatus.Added, repo.Index[filename].State);
}
}
@@ -236,7 +236,7 @@ public void CanStageANewFileWithAFullPath()
repo.Index.Stage(fullPath);
- repo.Index.Count.ShouldEqual(count + 1);
+ Assert.Equal(count + 1, repo.Index.Count);
repo.Index[filename].ShouldNotBeNull();
}
}
@@ -256,11 +256,11 @@ public void CanStageANewFileWithARelativePathContainingNativeDirectorySeparatorC
repo.Index.Stage(file);
- repo.Index.Count.ShouldEqual(count + 1);
+ Assert.Equal(count + 1, repo.Index.Count);
const string posixifiedPath = "Project/a_file.txt";
repo.Index[posixifiedPath].ShouldNotBeNull();
- repo.Index[posixifiedPath].Path.ShouldEqual(file);
+ Assert.Equal(file, repo.Index[posixifiedPath].Path);
}
}
@@ -306,14 +306,14 @@ public void CanUnStage(string relativePath, FileStatus currentStatus, bool doesC
using (var repo = new Repository(path.RepositoryPath))
{
int count = repo.Index.Count;
- (repo.Index[relativePath] != null).ShouldEqual(doesCurrentlyExistInTheIndex);
- repo.Index.RetrieveStatus(relativePath).ShouldEqual(currentStatus);
+ Assert.Equal(doesCurrentlyExistInTheIndex, (repo.Index[relativePath] != null));
+ Assert.Equal(currentStatus, repo.Index.RetrieveStatus(relativePath));
repo.Index.Unstage(relativePath);
- repo.Index.Count.ShouldEqual(count + expectedIndexCountVariation);
- (repo.Index[relativePath] != null).ShouldEqual(doesExistInTheIndexOnceStaged);
- repo.Index.RetrieveStatus(relativePath).ShouldEqual(expectedStatusOnceStaged);
+ Assert.Equal(count + expectedIndexCountVariation, repo.Index.Count);
+ Assert.Equal(doesExistInTheIndexOnceStaged, (repo.Index[relativePath] != null));
+ Assert.Equal(expectedStatusOnceStaged, repo.Index.RetrieveStatus(relativePath));
}
}
@@ -330,12 +330,12 @@ public void CanUnstageTheRemovalOfAFile()
string fullPath = Path.Combine(repo.Info.WorkingDirectory, filename);
Assert.False(File.Exists(fullPath));
- repo.Index.RetrieveStatus(filename).ShouldEqual(FileStatus.Removed);
+ Assert.Equal(FileStatus.Removed, repo.Index.RetrieveStatus(filename));
repo.Index.Unstage(filename);
- repo.Index.Count.ShouldEqual(count + 1);
+ Assert.Equal(count + 1, repo.Index.Count);
- repo.Index.RetrieveStatus(filename).ShouldEqual(FileStatus.Missing);
+ Assert.Equal(FileStatus.Missing, repo.Index.RetrieveStatus(filename));
}
}
@@ -358,47 +358,47 @@ public void CanRenameAFile()
using (var repo = Repository.Init(scd.DirectoryPath))
{
- repo.Index.Count.ShouldEqual(0);
+ Assert.Equal(0, repo.Index.Count);
const string oldName = "polite.txt";
string oldPath = Path.Combine(repo.Info.WorkingDirectory, oldName);
- repo.Index.RetrieveStatus(oldName).ShouldEqual(FileStatus.Nonexistent);
+ Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus(oldName));
File.WriteAllText(oldPath, "hello test file\n", Encoding.ASCII);
- repo.Index.RetrieveStatus(oldName).ShouldEqual(FileStatus.Untracked);
+ Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(oldName));
repo.Index.Stage(oldName);
- repo.Index.RetrieveStatus(oldName).ShouldEqual(FileStatus.Added);
+ Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(oldName));
// Generated through
// $ echo "hello test file" | git hash-object --stdin
const string expectedHash = "88df547706c30fa19f02f43cb2396e8129acfd9b";
- repo.Index[oldName].Id.Sha.ShouldEqual((expectedHash));
+ Assert.Equal(expectedHash, repo.Index[oldName].Id.Sha);
- repo.Index.Count.ShouldEqual(1);
+ Assert.Equal(1, repo.Index.Count);
Signature who = Constants.Signature;
repo.Commit("Initial commit", who, who);
- repo.Index.RetrieveStatus(oldName).ShouldEqual(FileStatus.Unaltered);
+ Assert.Equal(FileStatus.Unaltered, repo.Index.RetrieveStatus(oldName));
const string newName = "being.frakking.polite.txt";
repo.Index.Move(oldName, newName);
- repo.Index.RetrieveStatus(oldName).ShouldEqual(FileStatus.Removed);
- repo.Index.RetrieveStatus(newName).ShouldEqual(FileStatus.Added);
+ Assert.Equal(FileStatus.Removed, repo.Index.RetrieveStatus(oldName));
+ Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(newName));
- repo.Index.Count.ShouldEqual(1);
- repo.Index[newName].Id.Sha.ShouldEqual((expectedHash));
+ Assert.Equal(1, repo.Index.Count);
+ Assert.Equal(expectedHash, repo.Index[newName].Id.Sha);
who = who.TimeShift(TimeSpan.FromMinutes(5));
Commit commit = repo.Commit("Fix file name", who, who);
- repo.Index.RetrieveStatus(oldName).ShouldEqual(FileStatus.Nonexistent);
- repo.Index.RetrieveStatus(newName).ShouldEqual(FileStatus.Unaltered);
+ Assert.Equal(FileStatus.Nonexistent, repo.Index.RetrieveStatus(oldName));
+ Assert.Equal(FileStatus.Unaltered, repo.Index.RetrieveStatus(newName));
- commit.Tree[newName].Target.Id.Sha.ShouldEqual(expectedHash);
+ Assert.Equal(expectedHash, commit.Tree[newName].Target.Id.Sha);
}
}
@@ -412,13 +412,13 @@ public void CanMoveAnExistingFileOverANonExistingFile(string sourcePath, FileSta
TemporaryCloneOfTestRepo path = BuildTemporaryCloneOfTestRepo(StandardTestRepoWorkingDirPath);
using (var repo = new Repository(path.RepositoryPath))
{
- repo.Index.RetrieveStatus(sourcePath).ShouldEqual(sourceStatus);
- repo.Index.RetrieveStatus(destPath).ShouldEqual(destStatus);
+ Assert.Equal(sourceStatus, repo.Index.RetrieveStatus(sourcePath));
+ Assert.Equal(destStatus, repo.Index.RetrieveStatus(destPath));
repo.Index.Move(sourcePath, destPath);
- repo.Index.RetrieveStatus(sourcePath).ShouldEqual(sourcePostStatus);
- repo.Index.RetrieveStatus(destPath).ShouldEqual(destPostStatus);
+ Assert.Equal(sourcePostStatus, repo.Index.RetrieveStatus(sourcePath));
+ Assert.Equal(destPostStatus, repo.Index.RetrieveStatus(destPath));
}
}
@@ -452,7 +452,7 @@ private static void InvalidMoveUseCases(string sourcePath, FileStatus sourceStat
{
using (var repo = new Repository(StandardTestRepoPath))
{
- repo.Index.RetrieveStatus(sourcePath).ShouldEqual(sourceStatus);
+ Assert.Equal(sourceStatus, repo.Index.RetrieveStatus(sourcePath));
foreach (var destPath in destPaths)
{
@@ -474,14 +474,14 @@ public void CanRemoveAFile(string filename, FileStatus initialStatus, bool shoul
string fullpath = Path.Combine(repo.Info.WorkingDirectory, filename);
- File.Exists(fullpath).ShouldEqual(shouldInitiallyExist);
- repo.Index.RetrieveStatus(filename).ShouldEqual(initialStatus);
+ Assert.Equal(shouldInitiallyExist, File.Exists(fullpath));
+ Assert.Equal(initialStatus, repo.Index.RetrieveStatus(filename));
repo.Index.Remove(filename);
- repo.Index.Count.ShouldEqual(count - 1);
+ Assert.Equal(count - 1, repo.Index.Count);
Assert.False(File.Exists(fullpath));
- repo.Index.RetrieveStatus(filename).ShouldEqual(finalStatus);
+ Assert.Equal(finalStatus, repo.Index.RetrieveStatus(filename));
}
}
@@ -544,7 +544,7 @@ public void PathsOfIndexEntriesAreExpressedInNativeFormat()
ie.ShouldNotBeNull();
// Make sure that the (native) relFilePath and ie.Path are equal
- ie.Path.ShouldEqual(relFilePath);
+ Assert.Equal(relFilePath, ie.Path);
}
}
}
View
8 LibGit2Sharp.Tests/LazyFixture.cs
@@ -11,7 +11,7 @@ public class LazyFixture
public void CanReturnTheValue()
{
var lazy = new Lazy<int>(() => 2);
- lazy.Value.ShouldEqual(2);
+ Assert.Equal(2, lazy.Value);
}
[Fact]
@@ -22,7 +22,7 @@ public void IsLazilyEvaluated()
var evaluator = new Func<int>(() => ++i);
var lazy = new Lazy<int>(evaluator);
- lazy.Value.ShouldEqual(1);
+ Assert.Equal(1, lazy.Value);
}
[Fact]
@@ -34,8 +34,8 @@ public void IsEvaluatedOnlyOnce()
var lazy = new Lazy<int>(evaluator);
- lazy.Value.ShouldEqual(1);
- lazy.Value.ShouldEqual(1);
+ Assert.Equal(1, lazy.Value);
+ Assert.Equal(1, lazy.Value);
}
}
}
View
2 LibGit2Sharp.Tests/ObjectDatabaseFixture.cs
@@ -139,7 +139,7 @@ public void RemovingANonExistingEntryFromATreeDefinitionHasNoSideEffect()
Tree tree = repo.ObjectDatabase.CreateTree(td);
Assert.NotNull(tree);
- tree.ShouldEqual(head);
+ Assert.Equal(head, tree);
}
}
View
23 LibGit2Sharp.Tests/ObjectIdFixture.cs
@@ -1,4 +1,5 @@
using System;
+using System.Linq;
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
using Xunit.Extensions;
@@ -10,6 +11,8 @@ public class ObjectIdFixture
private const string validSha1 = "ce08fe4884650f067bd5703b6a59a8b3b3c99a09";
private const string validSha2 = "de08fe4884650f067bd5703b6a59a8b3b3c99a09";
+ private static byte[] bytes = new byte[] { 206, 8, 254, 72, 132, 101, 15, 6, 123, 213, 112, 59, 106, 89, 168, 179, 179, 201, 154, 9 };
+
[Theory]
[InlineData("Dummy", typeof(ArgumentException))]
[InlineData("", typeof(ArgumentException))]
@@ -24,28 +27,26 @@ public void PreventsFromBuildingWithAnInvalidSha(string malformedSha, Type expec
[Fact]
public void CanConvertOidToSha()
{
- var bytes = new byte[] { 206, 8, 254, 72, 132, 101, 15, 6, 123, 213, 112, 59, 106, 89, 168, 179, 179, 201, 154, 9 };
-
var id = new ObjectId(bytes);
- id.Sha.ShouldEqual(validSha1);
- id.ToString().ShouldEqual(validSha1);
+ Assert.Equal(validSha1, id.Sha);
+ Assert.Equal(validSha1, id.ToString());
}
[Fact]
public void CanConvertShaToOid()
{
var id = new ObjectId(validSha1);
- id.RawId.ShouldEqual(new byte[] { 206, 8, 254, 72, 132, 101, 15, 6, 123, 213, 112, 59, 106, 89, 168, 179, 179, 201, 154, 9 });
+ Assert.Equal(bytes, id.RawId);
}
[Fact]
public void CreatingObjectIdWithWrongNumberOfBytesThrows()
{
- var bytes = new byte[] { 206, 8, 254, 72, 132, 101, 15, 6, 123, 213, 112, 59, 106, 89, 168, 179, 179, 201, 154 };
+ var invalidBytes = new byte[] { 206, 8, 254, 72, 132, 101, 15, 6, 123, 213, 112, 59, 106, 89, 168, 179, 179, 201, 154 };
- Assert.Throws<ArgumentException>(() => { new ObjectId(bytes); });
+ Assert.Throws<ArgumentException>(() => { new ObjectId(invalidBytes); });
}
[Fact]
@@ -89,7 +90,7 @@ public void SimilarObjectIdsHaveSameHashCode()
var a = new ObjectId(validSha1);
var b = new ObjectId(validSha1);
- a.GetHashCode().ShouldEqual(b.GetHashCode());
+ Assert.Equal(b.GetHashCode(), a.GetHashCode());
}
[Theory]
@@ -107,17 +108,17 @@ public void TryParse(string maybeSha, bool isValidSha)
{
ObjectId parsedObjectId;
bool result = ObjectId.TryParse(maybeSha, out parsedObjectId);
- result.ShouldEqual(isValidSha);
+ Assert.Equal(isValidSha, result);
if (!result)
{
return;
}
parsedObjectId.ShouldNotBeNull();
- parsedObjectId.Sha.ShouldEqual(maybeSha);
+ Assert.Equal(maybeSha, parsedObjectId.Sha);
maybeSha.StartsWith(parsedObjectId.ToString(3)).ShouldBeTrue();
- parsedObjectId.ToString(42).ShouldEqual(maybeSha);
+ Assert.Equal(maybeSha, parsedObjectId.ToString(42));
}
}
}
View
72 LibGit2Sharp.Tests/ReferenceFixture.cs
@@ -25,10 +25,10 @@ public void CanCreateADirectReference()
{
var newRef = (DirectReference)repo.Refs.Create(name, "be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
newRef.ShouldNotBeNull();
- newRef.CanonicalName.ShouldEqual(name);
+ Assert.Equal(name, newRef.CanonicalName);
newRef.Target.ShouldNotBeNull();
- newRef.Target.Sha.ShouldEqual("be3563ae3f795b2b4353bcce3a527ad0a4f7f644");
- newRef.TargetIdentifier.ShouldEqual(newRef.Target.Sha);
+ Assert.Equal("be3563ae3f795b2b4353bcce3a527ad0a4f7f644", newRef.Target.Sha);
+ Assert.Equal(newRef.Target.Sha, newRef.TargetIdentifier);
repo.Refs[name].ShouldNotBeNull();
}
}
@@ -44,10 +44,10 @@ public void CanCreateASymbolicReference()
{
var newRef = (SymbolicReference)repo.Refs.Create(name, target);
newRef.ShouldNotBeNull();
- newRef.CanonicalName.ShouldEqual(name);
- newRef.Target.CanonicalName.ShouldEqual(target);
- newRef.TargetIdentifier.ShouldEqual(newRef.Target.CanonicalName);
- newRef.ResolveToDirectReference().Target.Sha.ShouldEqual("4c062a6361ae6959e06292c1fa5e2822d9c96345");
+ Assert.Equal(name, newRef.CanonicalName);
+ Assert.Equal(target, newRef.Target.CanonicalName);
+ Assert.Equal(newRef.Target.CanonicalName, newRef.TargetIdentifier);
+ Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", newRef.ResolveToDirectReference().Target.Sha);
repo.Refs[name].ShouldNotBeNull();
}
}
@@ -83,10 +83,10 @@ public void CanCreateAndOverwriteADirectReference()
{
var newRef = (DirectReference)repo.Refs.Create(name, target, true);
newRef.ShouldNotBeNull();
- newRef.CanonicalName.ShouldEqual(name);
+ Assert.Equal(name, newRef.CanonicalName);
newRef.Target.ShouldNotBeNull();
- newRef.Target.Sha.ShouldEqual(target);
- ((DirectReference)repo.Refs[name]).Target.Sha.ShouldEqual(target);
+ Assert.Equal(target, newRef.Target.Sha);
+ Assert.Equal(target, ((DirectReference)repo.Refs[name]).Target.Sha);
}
}
@@ -101,10 +101,10 @@ public void CanCreateAndOverwriteASymbolicReference()
{
var newRef = (SymbolicReference)repo.Refs.Create(name, target, true);
newRef.ShouldNotBeNull();
- newRef.CanonicalName.ShouldEqual(name);
+ Assert.Equal(name, newRef.CanonicalName);
newRef.Target.ShouldNotBeNull();
- newRef.ResolveToDirectReference().Target.Sha.ShouldEqual("a4a7dce85cf63874e984719f4fdd239f5145052f");
- ((SymbolicReference)repo.Refs["HEAD"]).Target.CanonicalName.ShouldEqual(target);
+ Assert.Equal("a4a7dce85cf63874e984719f4fdd239f5145052f", newRef.ResolveToDirectReference().Target.Sha);
+ Assert.Equal(target, ((SymbolicReference)repo.Refs["HEAD"]).Target.CanonicalName);
}
}
@@ -183,7 +183,7 @@ public void DeletingAReferenceDecreasesTheRefsCount()
List<string> refs2 = repo.Refs.Select(r => r.CanonicalName).ToList();
Assert.False(refs2.Contains(refName));
- refs2.Count.ShouldEqual(refs.Count - 1);
+ Assert.Equal(refs.Count - 1, refs2.Count);
}
}
@@ -215,7 +215,7 @@ public void CanListAllReferencesEvenCorruptedOnes()
Assert.Equal(expectedRefs, repo.Refs.Select(r => r.CanonicalName).ToArray());
- repo.Refs.Count().ShouldEqual(13);
+ Assert.Equal(13, repo.Refs.Count());
}
}
@@ -226,17 +226,17 @@ public void CanResolveHeadByName()
{
var head = (SymbolicReference)repo.Refs["HEAD"];
head.ShouldNotBeNull();
- head.CanonicalName.ShouldEqual("HEAD");
+ Assert.Equal("HEAD", head.CanonicalName);
head.Target.ShouldNotBeNull();
- head.Target.CanonicalName.ShouldEqual("refs/heads/master");
- head.ResolveToDirectReference().Target.Sha.ShouldEqual("4c062a6361ae6959e06292c1fa5e2822d9c96345");
+ Assert.Equal("refs/heads/master", head.Target.CanonicalName);
+ Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", head.ResolveToDirectReference().Target.Sha);
Assert.IsType<Commit>(((DirectReference)head.Target).Target);
Branch head2 = repo.Head;
- head2.CanonicalName.ShouldEqual("refs/heads/master");
+ Assert.Equal("refs/heads/master", head2.CanonicalName);
head2.Tip.ShouldNotBeNull();
- head2.Tip.ShouldEqual(head.ResolveToDirectReference().Target);
+ Assert.Equal(head.ResolveToDirectReference().Target, head2.Tip);
}
}
@@ -247,9 +247,9 @@ public void CanResolveReferenceToALightweightTag()
{
var lwTag = (DirectReference)repo.Refs["refs/tags/lw"];
lwTag.ShouldNotBeNull();
- lwTag.CanonicalName.ShouldEqual("refs/tags/lw");
+ Assert.Equal("refs/tags/lw", lwTag.CanonicalName);
lwTag.Target.ShouldNotBeNull();
- lwTag.Target.Sha.ShouldEqual("e90810b8df3e80c413d903f631643c716887138d");
+ Assert.Equal("e90810b8df3e80c413d903f631643c716887138d", lwTag.Target.Sha);
Assert.IsType<Commit>(lwTag.Target);
}
}
@@ -261,9 +261,9 @@ public void CanResolveReferenceToAnAnnotatedTag()
{
var annTag = (DirectReference)repo.Refs["refs/tags/test"];
annTag.ShouldNotBeNull();
- annTag.CanonicalName.ShouldEqual("refs/tags/test");
+ Assert.Equal("refs/tags/test", annTag.CanonicalName);
annTag.Target.ShouldNotBeNull();
- annTag.Target.Sha.ShouldEqual("b25fa35b38051e4ae45d4222e795f9df2e43f1d1");
+ Assert.Equal("b25fa35b38051e4ae45d4222e795f9df2e43f1d1", annTag.Target.Sha);
Assert.IsType<TagAnnotation>(annTag.Target);
}
}
@@ -275,9 +275,9 @@ public void CanResolveRefsByName()
{
var master = (DirectReference)repo.Refs["refs/heads/master"];
master.ShouldNotBeNull();
- master.CanonicalName.ShouldEqual("refs/heads/master");
+ Assert.Equal("refs/heads/master", master.CanonicalName);
master.Target.ShouldNotBeNull();
- master.Target.Sha.ShouldEqual("4c062a6361ae6959e06292c1fa5e2822d9c96345");
+ Assert.Equal("4c062a6361ae6959e06292c1fa5e2822d9c96345", master.Target.Sha);
Assert.IsType<Commit>(master.Target);
}
}
@@ -314,9 +314,9 @@ public void CanUpdateTargetOnReference()
Reference updated = repo.Refs.UpdateTarget(masterRef, sha);
master = repo.Refs[masterRef];
- master.ShouldEqual(updated);
+ Assert.Equal(updated, master);
- master.ResolveToDirectReference().Target.Sha.ShouldEqual(sha);
+ Assert.Equal(sha, master.ResolveToDirectReference().Target.Sha);
}
}
@@ -333,7 +333,7 @@ public void CanUpdateTargetOnSymbolicReference()
repo.Refs.UpdateTarget(newRef.CanonicalName, "refs/heads/test");
newRef = (SymbolicReference)repo.Refs[newRef.CanonicalName];
- newRef.ResolveToDirectReference().Target.ShouldEqual(repo.Refs["refs/heads/test"].ResolveToDirectReference().Target);
+ Assert.Equal(repo.Refs["refs/heads/test"].ResolveToDirectReference().Target, newRef.ResolveToDirectReference().Target);
repo.Refs.Delete(newRef.CanonicalName);
}
@@ -349,11 +349,11 @@ public void CanUpdateHeadWithEitherAnOidOrACanonicalHeadReference()
Reference direct = repo.Refs.UpdateTarget("HEAD", test.Tip.Sha);
(direct is DirectReference).ShouldBeTrue();
- direct.ShouldEqual(repo.Refs["HEAD"]);
+ Assert.Equal(repo.Refs["HEAD"], direct);
Reference symref = repo.Refs.UpdateTarget("HEAD", test.CanonicalName);
(symref is SymbolicReference).ShouldBeTrue();
- symref.ShouldEqual(repo.Refs["HEAD"]);
+ Assert.Equal(repo.Refs["HEAD"], symref);
}
}
@@ -407,7 +407,7 @@ public void CanMoveAReferenceToADeeperReferenceHierarchy()
Reference moved = repo.Refs.Move("refs/tags/test", newName);
moved.ShouldNotBeNull();
- moved.CanonicalName.ShouldEqual(newName);
+ Assert.Equal(newName, moved.CanonicalName);
}
}
@@ -423,7 +423,7 @@ public void CanMoveAReferenceToAUpperReferenceHierarchy()
repo.Refs.Create(oldName, repo.Head.CanonicalName);
Reference moved = repo.Refs.Move(oldName, newName);
moved.ShouldNotBeNull();
- moved.CanonicalName.ShouldEqual(newName);
+ Assert.Equal(newName, moved.CanonicalName);
}
}
@@ -437,7 +437,7 @@ public void CanMoveAReferenceToADifferentReferenceHierarchy()
Reference moved = repo.Refs.Move("refs/tags/test", newName);
moved.ShouldNotBeNull();
- moved.CanonicalName.ShouldEqual(newName);
+ Assert.Equal(newName, moved.CanonicalName);
}
}
@@ -493,7 +493,7 @@ public void MovingAReferenceDoesNotDecreaseTheRefsCount()
Assert.False(refs2.Contains(oldName));
refs2.Contains(newName).ShouldBeTrue();
- refs.Count.ShouldEqual(refs2.Count);
+ Assert.Equal(refs2.Count, refs.Count);
}
}
@@ -509,7 +509,7 @@ public void CanLookupAMovedReference()
Reference moved = repo.Refs.Move(oldName, newName);
Reference lookedUp = repo.Refs[newName];
- moved.ShouldEqual(lookedUp);
+ Assert.Equal(lookedUp, moved);
}
}
}
View
10 LibGit2Sharp.Tests/RemoteFixture.cs
@@ -12,8 +12,8 @@ public void CanGetRemoteOrigin()
{
Remote origin = repo.Remotes["origin"];
origin.ShouldNotBeNull();
- origin.Name.ShouldEqual("origin");
- origin.Url.ShouldEqual("c:/GitHub/libgit2sharp/Resources/testrepo.git");
+ Assert.Equal("origin", origin.Name);
+ Assert.Equal("c:/GitHub/libgit2sharp/Resources/testrepo.git", origin.Url);
}
}
@@ -39,7 +39,7 @@ public void CanEnumerateTheRemotes()
count++;
}
- count.ShouldEqual(1);
+ Assert.Equal(1, count);
}
}
@@ -54,13 +54,13 @@ public void CanCheckEqualityOfRemote()
oneOrigin.ShouldNotBeNull();
Remote otherOrigin = repo.Remotes["origin"];
- otherOrigin.ShouldEqual(oneOrigin);
+ Assert.Equal(oneOrigin, otherOrigin);
Remote createdRemote = repo.Remotes.Create("origin2", oneOrigin.Url);
Remote loadedRemote = repo.Remotes["origin2"];
loadedRemote.ShouldNotBeNull();
- loadedRemote.ShouldEqual(createdRemote);
+ Assert.Equal(createdRemote, loadedRemote);
loadedRemote.ShouldNotEqual(oneOrigin);
}
View
46 LibGit2Sharp.Tests/RepositoryFixture.cs
@@ -22,7 +22,7 @@ public void CanCreateBareRepo()
CheckGitConfigFile(dir);
repo.Info.WorkingDirectory.ShouldBeNull();
- repo.Info.Path.ShouldEqual(scd.RootedDirectoryPath + Path.DirectorySeparatorChar);
+ Assert.Equal(scd.RootedDirectoryPath + Path.DirectorySeparatorChar, repo.Info.Path);
repo.Info.IsBare.ShouldBeTrue();
AssertInitializedRepository(repo);
@@ -51,7 +51,7 @@ public void CanCreateStandardRepo()
CheckGitConfigFile(dir);
repo.Info.WorkingDirectory.ShouldNotBeNull();
- repo.Info.Path.ShouldEqual(Path.Combine(scd.RootedDirectoryPath, ".git" + Path.DirectorySeparatorChar));
+ Assert.Equal(Path.Combine(scd.RootedDirectoryPath, ".git" + Path.DirectorySeparatorChar), repo.Info.Path);
Assert.False(repo.Info.IsBare);
AssertIsHidden(repo.Info.Path);
@@ -73,7 +73,7 @@ private static void AssertIsHidden(string repoPath)
{
FileAttributes attribs = File.GetAttributes(repoPath);
- (attribs & FileAttributes.Hidden).ShouldEqual(FileAttributes.Hidden);
+ Assert.Equal(FileAttributes.Hidden, (attribs & FileAttributes.Hidden));
}
[Fact]
@@ -84,7 +84,7 @@ public void CanReinitARepository()
using (Repository repository = Repository.Init(scd.DirectoryPath))
using (Repository repository2 = Repository.Init(scd.DirectoryPath))
{
- repository.Info.Path.ShouldEqual(repository2.Info.Path);
+ Assert.Equal(repository2.Info.Path, repository.Info.Path);
}
}
@@ -103,24 +103,24 @@ private static void AssertInitializedRepository(Repository repo)
Reference headRef = repo.Refs["HEAD"];
headRef.ShouldNotBeNull();
- headRef.TargetIdentifier.ShouldEqual("refs/heads/master");
+ Assert.Equal("refs/heads/master", headRef.TargetIdentifier);
headRef.ResolveToDirectReference().ShouldBeNull();
repo.Head.ShouldNotBeNull();
repo.Head.IsCurrentRepositoryHead.ShouldBeTrue();
- repo.Head.CanonicalName.ShouldEqual(headRef.TargetIdentifier);
+ Assert.Equal(headRef.TargetIdentifier, repo.Head.CanonicalName);
repo.Head.Tip.ShouldBeNull();
- repo.Commits.Count().ShouldEqual(0);
- repo.Commits.QueryBy(new Filter { Since = repo.Head }).Count().ShouldEqual(0);
- repo.Commits.QueryBy(new Filter { Since = "HEAD" }).Count().ShouldEqual(0);
- repo.Commits.QueryBy(new Filter { Since = "refs/heads/master" }).Count().ShouldEqual(0);
-
+ Assert.Equal(0, repo.Commits.Count());
+ Assert.Equal(0, repo.Commits.QueryBy(new Filter { Since = repo.Head }).Count());
+ Assert.Equal(0, repo.Commits.QueryBy(new Filter { Since = "HEAD" }).Count());
+ Assert.Equal(0, repo.Commits.QueryBy(new Filter { Since = "refs/heads/master" }).Count());
+
repo.Head["subdir/I-do-not-exist"].ShouldBeNull();
- repo.Branches.Count().ShouldEqual(0);
- repo.Refs.Count().ShouldEqual(0);
- repo.Tags.Count().ShouldEqual(0);
+ Assert.Equal(0, repo.Branches.Count());
+ Assert.Equal(0, repo.Refs.Count());
+ Assert.Equal(0, repo.Tags.Count());
}
[Fact]
@@ -232,7 +232,7 @@ public void CanLookupSameObjectTwiceAndTheyAreEqual()
GitObject commit = repo.Lookup(commitSha);
GitObject commit2 = repo.Lookup(commitSha);
commit.Equals(commit2).ShouldBeTrue();
- commit.GetHashCode().ShouldEqual(commit2.GetHashCode());
+ Assert.Equal(commit2.GetHashCode(), commit.GetHashCode());
}
}
@@ -285,13 +285,13 @@ public void CanLookupWhithShortIdentifers()
Signature author = Constants.Signature;
Commit commit = repo.Commit("Initial commit", author, author);
- commit.Sha.ShouldEqual(expectedSha);
+ Assert.Equal(expectedSha, commit.Sha);
GitObject lookedUp1 = repo.Lookup(expectedSha);
- lookedUp1.ShouldEqual(commit);
+ Assert.Equal(commit, lookedUp1);
GitObject lookedUp2 = repo.Lookup(expectedAbbrevSha);
- lookedUp2.ShouldEqual(commit);
+ Assert.Equal(commit, lookedUp2);
}
}
@@ -313,35 +313,35 @@ public void LookingUpWithBadParamsThrows()
public void CanDiscoverABareRepoGivenTheRepoPath()
{
string path = Repository.Discover(BareTestRepoPath);
- path.ShouldEqual(Path.GetFullPath(BareTestRepoPath + Path.DirectorySeparatorChar));
+ Assert.Equal(Path.GetFullPath(BareTestRepoPath + Path.DirectorySeparatorChar), path);
}
[Fact]
public void CanDiscoverABareRepoGivenASubDirectoryOfTheRepoPath()
{
string path = Repository.Discover(Path.Combine(BareTestRepoPath, "objects/4a"));
- path.ShouldEqual(Path.GetFullPath(BareTestRepoPath + Path.DirectorySeparatorChar));
+ Assert.Equal(Path.GetFullPath(BareTestRepoPath + Path.DirectorySeparatorChar), path);
}
[Fact]
public void CanDiscoverAStandardRepoGivenTheRepoPath()
{
string path = Repository.Discover(StandardTestRepoPath);
- path.ShouldEqual(Path.GetFullPath(StandardTestRepoPath + Path.DirectorySeparatorChar));
+ Assert.Equal(Path.GetFullPath(StandardTestRepoPath + Path.DirectorySeparatorChar), path);
}
[Fact]
public void CanDiscoverAStandardRepoGivenASubDirectoryOfTheRepoPath()
{
string path = Repository.Discover(Path.Combine(StandardTestRepoPath, "objects/4a"));
- path.ShouldEqual(Path.GetFullPath(StandardTestRepoPath + Path.DirectorySeparatorChar));
+ Assert.Equal(Path.GetFullPath(StandardTestRepoPath + Path.DirectorySeparatorChar), path);
}
[Fact]
public void CanDiscoverAStandardRepoGivenTheWorkingDirPath()
{
string path = Repository.Discover(StandardTestRepoWorkingDirPath);
- path.ShouldEqual(Path.GetFullPath(StandardTestRepoPath + Path.DirectorySeparatorChar));
+ Assert.Equal(Path.GetFullPath(StandardTestRepoPath + Path.DirectorySeparatorChar), path);
}
[Fact]
View
24 LibGit2Sharp.Tests/ResetFixture.cs
@@ -30,7 +30,7 @@ public void SoftResetToTheHeadOfARepositoryDoesNotChangeTheTargetOfTheHead()
repo.Reset(ResetOptions.Soft, oldHead.CanonicalName);
- repo.Head.ShouldEqual(oldHead);
+ Assert.Equal(oldHead, repo.Head);
}
}
@@ -43,7 +43,7 @@ public void SoftResetSetsTheHeadToTheDereferencedCommitOfAChainedTag()
{
Tag tag = repo.Tags["test"];
repo.Reset(ResetOptions.Soft, tag.CanonicalName);
- repo.Head.Tip.Sha.ShouldEqual("e90810b8df3e80c413d903f631643c716887138d");
+ Assert.Equal("e90810b8df3e80c413d903f631643c716887138d", repo.Head.Tip.Sha);
}
}
@@ -85,25 +85,25 @@ private void AssertSoftReset(Func<Branch, string> branchIdentifierRetriever, boo
string branchIdentifier = branchIdentifierRetriever(branch);
repo.Checkout(branchIdentifier);
- repo.Info.IsHeadDetached.ShouldEqual(shouldHeadBeDetached);
+ Assert.Equal(shouldHeadBeDetached, repo.Info.IsHeadDetached);
string expectedHeadName = expectedHeadNameRetriever(branch);
- repo.Head.Name.ShouldEqual(expectedHeadName);
- repo.Head.Tip.Sha.ShouldEqual(branch.Tip.Sha);
+ Assert.Equal(expectedHeadName, repo.Head.Name);
+ Assert.Equal(branch.Tip.Sha, repo.Head.Tip.Sha);
/* Reset --soft the Head to a tag through its canonical name */
repo.Reset(ResetOptions.Soft, tag.CanonicalName);
- repo.Head.Name.ShouldEqual(expectedHeadName);
- repo.Head.Tip.Id.ShouldEqual(tag.Target.Id);
+ Assert.Equal(expectedHeadName, repo.Head.Name);
+ Assert.Equal(tag.Target.Id, repo.Head.Tip.Id);
- repo.Index.RetrieveStatus("a.txt").ShouldEqual(FileStatus.Staged);
+ Assert.Equal(FileStatus.Staged, repo.Index.RetrieveStatus("a.txt"));
/* Reset --soft the Head to a commit through its sha */
repo.Reset(ResetOptions.Soft, branch.Tip.Sha);
- repo.Head.Name.ShouldEqual(expectedHeadName);
- repo.Head.Tip.Sha.ShouldEqual(branch.Tip.Sha);
+ Assert.Equal(expectedHeadName, repo.Head.Name);
+ Assert.Equal(branch.Tip.Sha, repo.Head.Tip.Sha);
- repo.Index.RetrieveStatus("a.txt").ShouldEqual(FileStatus.Unaltered);
+ Assert.Equal(FileStatus.Unaltered, repo.Index.RetrieveStatus("a.txt"));
}
}
@@ -140,7 +140,7 @@ public void MixedResetRefreshesTheIndex()
repo.Reset(ResetOptions.Mixed, tag.CanonicalName);
- repo.Index.RetrieveStatus("a.txt").ShouldEqual(FileStatus.Modified);
+ Assert.Equal(FileStatus.Modified, repo.Index.RetrieveStatus("a.txt"));
}
}
View
60 LibGit2Sharp.Tests/StatusFixture.cs
@@ -14,7 +14,7 @@ public void CanRetrieveTheStatusOfAFile()
using (var repo = new Repository(StandardTestRepoPath))
{
FileStatus status = repo.Index.RetrieveStatus("new_tracked_file.txt");
- status.ShouldEqual(FileStatus.Added);
+ Assert.Equal(FileStatus.Added, status);
}
}
@@ -38,36 +38,36 @@ public void CanRetrieveTheStatusOfTheWholeWorkingDirectory()
RepositoryStatus status = repo.Index.RetrieveStatus();
IndexEntry indexEntry = repo.Index[file];
- indexEntry.State.ShouldEqual(FileStatus.Staged);
+ Assert.Equal(FileStatus.Staged, indexEntry.State);
status.ShouldNotBeNull();
- status.Count().ShouldEqual(6);
+ Assert.Equal(6, status.Count());
status.IsDirty.ShouldBeTrue();
- status.Untracked.Single().ShouldEqual("new_untracked_file.txt");
- status.Modified.Single().ShouldEqual("modified_unstaged_file.txt");
- status.Missing.Single().ShouldEqual("deleted_unstaged_file.txt");
- status.Added.Single().ShouldEqual("new_tracked_file.txt");
- status.Staged.Single().ShouldEqual(file);
- status.Removed.Single().ShouldEqual("deleted_staged_file.txt");
+ Assert.Equal("new_untracked_file.txt", status.Untracked.Single());
+ Assert.Equal("modified_unstaged_file.txt", status.Modified.Single());
+ Assert.Equal("deleted_unstaged_file.txt", status.Missing.Single());
+ Assert.Equal("new_tracked_file.txt", status.Added.Single());
+ Assert.Equal(file, status.Staged.Single());
+ Assert.Equal("deleted_staged_file.txt", status.Removed.Single());
File.AppendAllText(Path.Combine(repo.Info.WorkingDirectory, file),
"Tclem's favorite commit message: boom");
- indexEntry.State.ShouldEqual(FileStatus.Staged | FileStatus.Modified);
+ Assert.Equal(FileStatus.Staged | FileStatus.Modified, indexEntry.State);
RepositoryStatus status2 = repo.Index.RetrieveStatus();
status2.ShouldNotBeNull();
- status2.Count().ShouldEqual(6);
+ Assert.Equal(6, status2.Count());
status2.IsDirty.ShouldBeTrue();
- status2.Untracked.Single().ShouldEqual("new_untracked_file.txt");
+ Assert.Equal("new_untracked_file.txt", status2.Untracked.Single());
Assert.Equal(new[] { file, "modified_unstaged_file.txt" }, status2.Modified);
- status2.Missing.Single().ShouldEqual("deleted_unstaged_file.txt");
- status2.Added.Single().ShouldEqual("new_tracked_file.txt");
- status2.Staged.Single().ShouldEqual(file);
- status2.Removed.Single().ShouldEqual("deleted_staged_file.txt");
+ Assert.Equal("deleted_unstaged_file.txt", status2.Missing.Single());
+ Assert.Equal("new_tracked_file.txt", status2.Added.Single());
+ Assert.Equal(file, status2.Staged.Single());
+ Assert.Equal("deleted_staged_file.txt", status2.Removed.Single());
}
}
@@ -80,15 +80,15 @@ public void CanRetrieveTheStatusOfANewRepository()
{
RepositoryStatus status = repo.Index.RetrieveStatus();
status.ShouldNotBeNull();
- status.Count().ShouldEqual(0);
+ Assert.Equal(0, status.Count());
Assert.False(status.IsDirty);
- status.Untracked.Count().ShouldEqual(0);
- status.Modified.Count().ShouldEqual(0);
- status.Missing.Count().ShouldEqual(0);
- status.Added.Count().ShouldEqual(0);
- status.Staged.Count().ShouldEqual(0);
- status.Removed.Count().ShouldEqual(0);
+ Assert.Equal(0, status.Untracked.Count());
+ Assert.Equal(0, status.Modified.Count());
+ Assert.Equal(0, status.Missing.Count());
+ Assert.Equal(0, status.Added.Count());
+ Assert.Equal(0, status.Staged.Count());
+ Assert.Equal(0, status.Removed.Count());
}
}
@@ -117,13 +117,13 @@ public void RetrievingTheStatusOfARepositoryReturnNativeFilePaths()
// Get the repository status
RepositoryStatus repoStatus = repo.Index.RetrieveStatus();
- repoStatus.Count().ShouldEqual(1);
+ Assert.Equal(1, repoStatus.Count());
StatusEntry statusEntry = repoStatus.Single();
string expectedPath = string.Format("{0}{1}{2}", directoryName, Path.DirectorySeparatorChar, fileName);
- statusEntry.FilePath.ShouldEqual(expectedPath);
+ Assert.Equal(expectedPath, statusEntry.FilePath);
- repoStatus.Added.Single().ShouldEqual(statusEntry.FilePath);
+ Assert.Equal(statusEntry.FilePath, repoStatus.Added.Single());
}
}
@@ -145,9 +145,9 @@ public void RetrievingTheStatusOfAnEmptyRepositoryHonorsTheGitIgnoreDirectives()
File.WriteAllText(gitignorePath, "*.txt" + Environment.NewLine);
RepositoryStatus newStatus = repo.Index.RetrieveStatus();
- newStatus.Untracked.Single().ShouldEqual(".gitignore");
+ Assert.Equal(".gitignore", newStatus.Untracked.Single());
- repo.Index.RetrieveStatus(relativePath).ShouldEqual(FileStatus.Ignored);
+ Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(relativePath));
Assert.Equal(new[] { relativePath }, newStatus.Ignored);
}
}
@@ -236,9 +236,9 @@ public void RetrievingTheStatusOfTheRepositoryHonorsTheGitIgnoreDirectives()
*/
RepositoryStatus newStatus = repo.Index.RetrieveStatus();
- newStatus.Untracked.Single().ShouldEqual(".gitignore");
+ Assert.Equal(".gitignore", newStatus.Untracked.Single());
- repo.Index.RetrieveStatus(relativePath).ShouldEqual(FileStatus.Ignored);
+ Assert.Equal(FileStatus.Ignored, repo.Index.RetrieveStatus(relativePath));
Assert.Equal(new[] { relativePath, "new_untracked_file.txt" }, newStatus.Ignored);
}
}
View
82 LibGit2Sharp.Tests/TagFixture.cs
@@ -75,16 +75,16 @@ public void CanCreateATagWithNameContainingASlash()
Tag lwTag = repo.Tags.Create(lwTagName, commitE90810BSha);
lwTag.ShouldNotBeNull();
Assert.False(lwTag.IsAnnotated);
- lwTag.Target.Sha.ShouldEqual(commitE90810BSha);
- lwTag.Name.ShouldEqual(lwTagName);
+ Assert.Equal(commitE90810BSha, lwTag.Target.Sha);
+ Assert.Equal(lwTagName, lwTag.Name);
const string anTagName = lwTagName + "_as_well";
Tag anTag = repo.Tags.Create(anTagName, commitE90810BSha, signatureNtk, "a nice message");
anTag.ShouldNotBeNull();
anTag.IsAnnotated.ShouldBeTrue();
- anTag.Target.Sha.ShouldEqual(commitE90810BSha);
- anTag.Annotation.Target.ShouldEqual(anTag.Target);
- anTag.Name.ShouldEqual(anTagName);
+ Assert.Equal(commitE90810BSha, anTag.Target.Sha);
+ Assert.Equal(anTag.Target, anTag.Annotation.Target);
+ Assert.Equal(anTagName, anTag.Name);
}
}
@@ -134,7 +134,7 @@ public void CanCreateAnAnnotatedTagWithAnEmptyMessage()
Tag newTag = repo.ApplyTag("empty-annotated-tag", signatureNtk, string.Empty);
newTag.ShouldNotBeNull();
newTag.IsAnnotated.ShouldBeTrue();
- newTag.Annotation.Message.ShouldEqual(string.Empty);
+ Assert.Equal(string.Empty, newTag.Annotation.Message);
}
}
@@ -160,10 +160,10 @@ public void CreatingAnAnnotatedTagIsDeterministic()
using (var repo = new Repository(path.RepositoryPath))
{
Tag newTag = repo.Tags.Create(tagName, commitE90810BSha, signatureNtk, tagMessage);
- newTag.Target.Sha.ShouldEqual(commitE90810BSha);
+ Assert.Equal(commitE90810BSha, newTag.Target.Sha);
newTag.IsAnnotated.ShouldBeTrue();
- newTag.Annotation.Sha.ShouldEqual("26623eee75440d63e10dcb752b88a0004c914161");
- newTag.Annotation.Target.Sha.ShouldEqual(commitE90810BSha);
+ Assert.Equal("26623eee75440d63e10dcb752b88a0004c914161", newTag.Annotation.Sha);
+ Assert.Equal(commitE90810BSha, newTag.Annotation.Target.Sha);
}
}
@@ -230,10 +230,10 @@ public void CanCreateATagForImplicitHead()
Tag tag = repo.ApplyTag("mytag");
tag.ShouldNotBeNull();
- tag.Target.Id.ShouldEqual(repo.Head.Tip.Id);
+ Assert.Equal(repo.Head.Tip.Id, tag.Target.Id);
Tag retrievedTag = repo.Tags[tag.CanonicalName];
- tag.ShouldEqual(retrievedTag);
+ Assert.Equal(retrievedTag, tag);
}
}
@@ -274,10 +274,10 @@ public void CanCreateATagUsingHead()
Tag tag = repo.ApplyTag("mytag", "HEAD");
tag.ShouldNotBeNull();
- tag.Target.Id.ShouldEqual(repo.Head.Tip.Id);
+ Assert.Equal(repo.Head.Tip.Id, tag.Target.Id);
Tag retrievedTag = repo.Tags[tag.CanonicalName];
- tag.ShouldEqual(retrievedTag);
+ Assert.Equal(retrievedTag, tag);
}
}
@@ -293,10 +293,10 @@ public void CanCreateATagPointingToATree()
Tag tag = repo.ApplyTag("tree-tag", tree.Sha);
tag.ShouldNotBeNull();
Assert.False(tag.IsAnnotated);
- tag.Target.Id.ShouldEqual(tree.Id);
+ Assert.Equal(tree.Id, tag.Target.Id);
- repo.Lookup(tag.Target.Id).ShouldEqual(tree);
- repo.Tags[tag.Name].ShouldEqual(tag);
+ Assert.Equal(tree, repo.Lookup(tag.Target.Id));
+ Assert.Equal(tag, repo.Tags[tag.Name]);
}
}
@@ -312,10 +312,10 @@ public void CanCreateATagPointingToABlob()
Tag tag = repo.ApplyTag("blob-tag", blob.Sha);
tag.ShouldNotBeNull();
Assert.False(tag.IsAnnotated);
- tag.Target.Id.ShouldEqual(blob.Id);
+ Assert.Equal(blob.Id, tag.Target.Id);
- repo.Lookup(tag.Target.Id).ShouldEqual(blob);
- repo.Tags[tag.Name].ShouldEqual(tag);
+ Assert.Equal(blob, repo.Lookup(tag.Target.Id));
+ Assert.Equal(tag, repo.Tags[tag.Name]);
}
}
@@ -331,11 +331,11 @@ public void CreatingALightweightTagPointingToATagAnnotationGeneratesAnAnnotatedT
Tag tag = repo.ApplyTag("lightweight-tag", annotation.Sha);
tag.ShouldNotBeNull();
tag.IsAnnotated.ShouldBeTrue();
- tag.Target.Id.ShouldEqual(annotation.Target.Id);
- tag.Annotation.ShouldEqual(annotation);
+ Assert.Equal(annotation.Target.Id, tag.Target.Id);
+ Assert.Equal(annotation, tag.Annotation);
- repo.Lookup(tag.Annotation.Id).ShouldEqual(annotation);
- repo.Tags[tag.Name].ShouldEqual(tag);
+ Assert.Equal(annotation, repo.Lookup(tag.Annotation.Id));
+ Assert.Equal(tag, repo.Tags[tag.Name]);
}
}
@@ -351,10 +351,10 @@ public void CanCreateAnAnnotatedTagPointingToATagAnnotation()
Tag tag = repo.ApplyTag("annotatedtag-tag", annotation.Sha, signatureNtk, "A new annotation");
tag.ShouldNotBeNull();
tag.IsAnnotated.ShouldBeTrue();
- tag.Annotation.Target.Id.ShouldEqual(annotation.Id);
+ Assert.Equal(annotation.Id, tag.Annotation.Target.Id);
tag.Annotation.ShouldNotEqual(annotation);
- repo.Tags[tag.Name].ShouldEqual(tag);
+ Assert.Equal(tag, repo.Tags[tag.Name]);
}
}
@@ -497,7 +497,7 @@ public void DeletingATagDecreasesTheTagsCount()
List<string> tags2 = repo.Tags.Select(r => r.Name).ToList();
Assert.False(tags2.Contains(tagName));
- tags2.Count.ShouldEqual(tags.Count - 1);
+ Assert.Equal(tags.Count - 1, tags2.Count);
}
}
@@ -529,7 +529,7 @@ public void CanListTags()
{
Assert.Equal(expectedTags, repo.Tags.Select(t => t.Name).ToArray());
- repo.Tags.Count().ShouldEqual(4);
+ Assert.Equal(4, repo.Tags.Count());
}
}
@@ -542,7 +542,7 @@ public void CanListAllTagsInAEmptyRepository()
using (var repo = Repository.Init(scd.DirectoryPath))
{
repo.Info.IsEmpty.ShouldBeTrue();
- repo.Tags.Count().ShouldEqual(0);
+ Assert.Equal(0, repo.Tags.Count());
}
}
@@ -568,8 +568,8 @@ public void CanLookupALightweightTag()
{
Tag tag = repo.Tags["lw"];
tag.ShouldNotBeNull();
- tag.Name.ShouldEqual("lw");
- tag.Target.Sha.ShouldEqual(commitE90810BSha);
+ Assert.Equal("lw", tag.Name);
+ Assert.Equal(commitE90810BSha, tag.Target.Sha);
Assert.False(tag.IsAnnotated);
tag.Annotation.ShouldBeNull();
@@ -583,13 +583,13 @@ public void CanLookupATagByItsCanonicalName()
{
Tag tag = repo.Tags["refs/tags/lw"];
tag.ShouldNotBeNull();
- tag.Name.ShouldEqual("lw");
+ Assert.Equal("lw", tag.Name);
Tag tag2 = repo.Tags["refs/tags/lw"];
tag2.ShouldNotBeNull();
- tag2.Name.ShouldEqual("lw");
+ Assert.Equal("lw", tag2.Name);
- tag2.ShouldEqual(tag);
+ Assert.Equal(tag, tag2);
(tag2 == tag).ShouldBeTrue();
}
}
@@ -601,16 +601,16 @@ public void CanLookupAnAnnotatedTag()
{
Tag tag = repo.Tags["e90810b"];
tag.ShouldNotBeNull();
- tag.Name.ShouldEqual("e90810b");
- tag.Target.Sha.ShouldEqual(commitE90810BSha);
+ Assert.Equal("e90810b", tag.Name);
+ Assert.Equal(commitE90810BSha, tag.Target.Sha);
tag.IsAnnotated.ShouldBeTrue();
- tag.Annotation.Sha.ShouldEqual(tagE90810BSha);
- tag.Annotation.Tagger.Email.ShouldEqual("tanoku@gmail.com");
- tag.Annotation.Tagger.Name.ShouldEqual("Vicent Marti");
- tag.Annotation.Tagger.When.ShouldEqual(DateTimeOffset.Parse("2010-08-12 03:59:17 +0200"));
- tag.Annotation.Message.ShouldEqual("This is a very simple tag.\n");
- tag.Annotation.Target.Sha.ShouldEqual(commitE90810BSha);
+ Assert.Equal(tagE90810BSha, tag.Annotation.Sha);
+ Assert.Equal("tanoku@gmail.com", tag.Annotation.Tagger.Email);
+ Assert.Equal("Vicent Marti", tag.Annotation.Tagger.Name);
+ Assert.Equal(DateTimeOffset.Parse("2010-08-12 03:59:17 +0200"), tag.Annotation.Tagger.When);
+ Assert.Equal("This is a very simple tag.\n", tag.Annotation.Message);
+ Assert.Equal(commitE90810BSha, tag.Annotation.Target.Sha);
}
}
View
10 LibGit2Sharp.Tests/TestHelpers/AssertExtensions.cs
@@ -24,16 +24,6 @@ public static void ShouldBeTrue(this bool currentObject)
Assert.True(currentObject);
}
- public static void ShouldEqual(this object compareFrom, object compareTo)
- {
- Assert.Equal(compareTo, compareFrom);
- }
-
- public static void ShouldEqual<T>(this T compareFrom, T compareTo)
- {
- Assert.Equal(compareTo, compareFrom);
- }
-
public static void ShouldNotBeNull(this object currentObject)
{
Assert.NotNull(currentObject);
View
26 LibGit2Sharp.Tests/TreeFixture.cs
@@ -17,7 +17,7 @@ public void CanCompareTwoTreeEntries()
var tree = repo.Lookup<Tree>(sha);
TreeEntry treeEntry1 = tree["README"];