forked from haacked/seegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added equality tests for commits and edges
- Loading branch information
Showing
5 changed files
with
195 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using SeeGit; | ||
using Xunit; | ||
|
||
namespace UnitTests.Models | ||
{ | ||
public class CommitEdgeTests | ||
{ | ||
public class TheEqualsMethod | ||
{ | ||
[Fact] | ||
public void ReturnsTrueIfSourceAndTargetAreSame() | ||
{ | ||
var edge = new CommitEdge(new CommitVertex("sha-child", "child commit"), | ||
new CommitVertex("sha-parent", "parent commit")); | ||
var other = new CommitEdge(new CommitVertex("sha-child", "another child commit"), | ||
new CommitVertex("sha-parent", "another parent commit")); | ||
|
||
Assert.True(edge.Equals(other)); | ||
} | ||
|
||
[Fact] | ||
public void ReturnsFalseIfSourceAndTargetAreSame() | ||
{ | ||
var edge = new CommitEdge(new CommitVertex("sha1-child", "child commit"), | ||
new CommitVertex("sha-parent", "parent commit")); | ||
var other = new CommitEdge(new CommitVertex("sha-child", "another child commit"), | ||
new CommitVertex("sha-parent", "another parent commit")); | ||
|
||
Assert.False(edge.Equals(other)); | ||
} | ||
|
||
[Fact] | ||
public void ReturnsFalseWhenComparedToNull() | ||
{ | ||
var edge = new CommitEdge(new CommitVertex("sha1-child", "child commit"), | ||
new CommitVertex("sha-parent", "parent commit")); | ||
|
||
Assert.False(edge.Equals(null)); | ||
} | ||
} | ||
|
||
public class TheEqualityOperator | ||
{ | ||
[Fact] | ||
public void ReturnsTrueIfShaAreSame() | ||
{ | ||
var edge = new CommitEdge(new CommitVertex("sha-child", "child commit"), | ||
new CommitVertex("sha-parent", "parent commit")); | ||
var other = new CommitEdge(new CommitVertex("sha-child", "another child commit"), | ||
new CommitVertex("sha-parent", "another parent commit")); | ||
|
||
Assert.True(edge == other); | ||
} | ||
|
||
[Fact] | ||
public void ReturnsFalseIfEitherShaIsDifferent() | ||
{ | ||
var edge = new CommitEdge(new CommitVertex("sha-child", "child commit"), | ||
new CommitVertex("sha-parent", "parent commit")); | ||
var other = new CommitEdge(new CommitVertex("sha1-child", "another child commit"), | ||
new CommitVertex("sha-parent", "another parent commit")); | ||
|
||
Assert.False(edge == other); | ||
Assert.True(edge != other); | ||
} | ||
|
||
[Fact] | ||
public void ReturnsFalseWhenComparedToNull() | ||
{ | ||
var edge = new CommitEdge(new CommitVertex("sha-child", "child commit"), | ||
new CommitVertex("sha-parent", "parent commit")); | ||
|
||
Assert.False(edge == null); | ||
Assert.True(edge != null); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using SeeGit; | ||
using Xunit; | ||
|
||
namespace UnitTests.Models | ||
{ | ||
public class CommitVertexTests | ||
{ | ||
public class TheCtor | ||
{ | ||
[Fact] | ||
public void SetsProperties() | ||
{ | ||
var commit = new CommitVertex("shasha", "commit message"); | ||
|
||
Assert.Equal("shasha", commit.Sha); | ||
Assert.Equal("commit message", commit.Message); | ||
Assert.NotNull(commit.Branches); | ||
} | ||
} | ||
|
||
public class TheEqualsMethod | ||
{ | ||
[Fact] | ||
public void ReturnsTrueIfShasAreSame() | ||
{ | ||
var commit = new CommitVertex("sha", "whatever"); | ||
var other = new CommitVertex("sha", "doesn't matter"); | ||
|
||
Assert.True(commit.Equals(other)); | ||
} | ||
|
||
[Fact] | ||
public void ReturnsFalseIfShasAreDifferent() | ||
{ | ||
var commit = new CommitVertex("sha1", "whatever"); | ||
var other = new CommitVertex("sha2", "doesn't matter"); | ||
|
||
Assert.False(commit.Equals(other)); | ||
} | ||
|
||
[Fact] | ||
public void ReturnsFalseWhenComparedToNull() | ||
{ | ||
Assert.False(new CommitVertex("sha", "message").Equals(null)); | ||
} | ||
} | ||
|
||
public class TheEqualityOperator | ||
{ | ||
[Fact] | ||
public void ReturnsTrueIfShasAreSame() | ||
{ | ||
var commit = new CommitVertex("sha", "whatever"); | ||
var other = new CommitVertex("sha", "doesn't matter"); | ||
|
||
Assert.True(commit == other); | ||
} | ||
|
||
[Fact] | ||
public void ReturnsFalseIfShasAreDifferent() | ||
{ | ||
var commit = new CommitVertex("sha", "whatever"); | ||
var other = new CommitVertex("sha1", "doesn't matter"); | ||
|
||
Assert.False(commit == other); | ||
Assert.True(commit != other); | ||
} | ||
|
||
[Fact] | ||
public void ReturnsFalseWhenComparedToNull() | ||
{ | ||
Assert.False(new CommitVertex("sha", "message") == null); | ||
Assert.True(new CommitVertex("sha", "message") != null); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters