public void EqualsObjectTest() { var commit = new GitCommit() { Sha = GitObjectId.Parse(this.shaAsByteArray), }; var commit2 = new GitCommit() { Sha = GitObjectId.Parse(this.shaAsByteArray), }; var emptyCommit = new GitCommit() { Sha = GitObjectId.Empty, }; // Must be equal to itself Assert.True(commit.Equals((object)commit)); Assert.True(commit.Equals((object)commit2)); // Not equal to null Assert.False(commit.Equals(null)); // Not equal to other representations of the commit Assert.False(commit.Equals(this.shaAsByteArray)); Assert.False(commit.Equals(commit.Sha)); // Not equal to other object ids Assert.False(commit.Equals((object)emptyCommit)); }
public void EqualsCommitTest() { var commit = new GitCommit() { Sha = GitObjectId.Parse(this.shaAsByteArray), }; var commit2 = new GitCommit() { Sha = GitObjectId.Parse(this.shaAsByteArray), }; var emptyCommit = new GitCommit() { Sha = GitObjectId.Empty, }; // Must be equal to itself Assert.True(commit.Equals(commit2)); Assert.True(commit.Equals(commit2)); // Not equal to other object ids Assert.False(commit.Equals(emptyCommit)); }
public void TestGitCommit() { DateTime now = DateTime.Now; DateTime wayBack = new DateTime(2000, 2, 5); GitCommit commitA = new GitCommit("testA", now, "commit A", Guid.NewGuid().ToString()) { Branch = "commitABranch", Url = "wrmcodeblocks.com" }; GitCommit commitB = new GitCommit("testB", now, "commit B", Guid.NewGuid().ToString()) { Branch = "commitBBranch", Url = "urlB" }; GitCommit commitC = new GitCommit("testC", now, "commit C", Guid.NewGuid().ToString()); GitCommit commitD = new GitCommit("testD", wayBack, "work back here?", Guid.NewGuid().ToString()); _instance.AddCommit(commitA); _instance.AddCommit(commitA); _instance.AddCommit(commitA); Assert.IsTrue(_instance.GetCommits(now).Count == 1);// Test duplicate safety feature. _instance.AddCommit(commitB); Assert.IsTrue(_instance.GetCommits(now).Count == 2); _instance.AddCommit(commitC); _instance.AddCommit(commitD); Assert.IsTrue(_instance.GetCommits(now).Count == 3); var commits = _instance.GetCommits(now); Assert.IsTrue(commits.Count == 3); Assert.IsTrue(commitA.Equals(commits[0])); Assert.IsTrue(commitB.Equals(commits[1])); Assert.IsTrue(commitC.Equals(commits[2])); _instance.RemoveCommit(commitA); Assert.IsTrue(_instance.GetCommits(now).Count == 2); _instance.RemoveCommit(commitB); Assert.IsTrue(_instance.GetCommits(now).Count == 1); _instance.RemoveCommit(commitC); Assert.IsTrue(_instance.GetCommits(now).Count == 0); Assert.IsTrue(_instance.GetCommits().Count == 1); }