forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EqualityFixture.cs
52 lines (45 loc) · 1.54 KB
/
EqualityFixture.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using LibGit2Sharp.Tests.TestHelpers;
using Xunit;
namespace LibGit2Sharp.Tests
{
public class EqualityFixture : BaseFixture
{
[Fact]
public void EqualityHelperCanTestNullInEquals()
{
var one = new ObjectWithEquality();
var two = new ObjectWithEquality();
var three = new ObjectWithEquality(ObjectId.Zero);
var four = new ObjectWithEquality(ObjectId.Zero);
Assert.True(one.Equals(one));
Assert.True(two.Equals(two));
Assert.True(three.Equals(four));
Assert.True(four.Equals(three));
Assert.False(one.Equals(three));
Assert.False(three.Equals(one));
}
[Fact]
public void EqualityHelperCanTestNullInHashCode()
{
var one = new ObjectWithEquality();
var two = new ObjectWithEquality();
var three = new ObjectWithEquality(ObjectId.Zero);
var four = new ObjectWithEquality(ObjectId.Zero);
Assert.Equal(one.GetHashCode(), two.GetHashCode());
Assert.Equal(three.GetHashCode(), four.GetHashCode());
Assert.NotEqual(one.GetHashCode(), three.GetHashCode());
}
private class ObjectWithEquality : GitObject
{
private readonly ObjectId id;
public ObjectWithEquality(ObjectId id = null)
{
this.id = id;
}
public override ObjectId Id
{
get { return id; }
}
}
}
}