Skip to content

Commit d9d8abe

Browse files
author
Jake Ginnivan
committed
Added equality and formatting members to ConventionResult
1 parent a0a3088 commit d9d8abe

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

TestStack.ConventionTests/Internal/ConventionResult.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,44 @@ public void WithFormattedResult(string formattedResult, string recommendedFileEx
3131
FormattedResult = formattedResult;
3232
RecommendedFileExtension = recommendedFileExtension;
3333
}
34+
35+
protected bool Equals(ConventionResult other)
36+
{
37+
return DataType == other.DataType && string.Equals(ConventionTitle, other.ConventionTitle) && string.Equals(DataDescription, other.DataDescription);
38+
}
39+
40+
public override bool Equals(object obj)
41+
{
42+
if (ReferenceEquals(null, obj)) return false;
43+
if (ReferenceEquals(this, obj)) return true;
44+
if (obj.GetType() != this.GetType()) return false;
45+
return Equals((ConventionResult) obj);
46+
}
47+
48+
public override int GetHashCode()
49+
{
50+
unchecked
51+
{
52+
var hashCode = (DataType != null ? DataType.GetHashCode() : 0);
53+
hashCode = (hashCode*397) ^ (ConventionTitle != null ? ConventionTitle.GetHashCode() : 0);
54+
hashCode = (hashCode*397) ^ (DataDescription != null ? DataDescription.GetHashCode() : 0);
55+
return hashCode;
56+
}
57+
}
58+
59+
public static bool operator ==(ConventionResult left, ConventionResult right)
60+
{
61+
return Equals(left, right);
62+
}
63+
64+
public static bool operator !=(ConventionResult left, ConventionResult right)
65+
{
66+
return !Equals(left, right);
67+
}
68+
69+
public override string ToString()
70+
{
71+
return string.Format("FormattedResult: {0}, DataDescription: {1}, ConventionTitle: {2}, DataType: {3}, HasData: {4}, RecommendedFileExtension: {5}", FormattedResult, DataDescription, ConventionTitle, DataType, HasData, RecommendedFileExtension);
72+
}
3473
}
3574
}

0 commit comments

Comments
 (0)