Skip to content

Commit

Permalink
Added test for StratusAsset.Equals(object)
Browse files Browse the repository at this point in the history
Meh.
  • Loading branch information
kf6kjg committed Feb 12, 2018
1 parent 71d1da3 commit cfca947
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
1 change: 1 addition & 0 deletions Source/Chattel/CloudFilesProvider/StratusAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ public override bool Equals(object obj) {
/// <see cref="T:InWorldz.Data.Assets.Stratus.StratusAsset"/>; otherwise, <c>false</c>.</returns>
public bool Equals(StratusAsset other) {
return
other != null &&
Id == other.Id &&
Type == other.Type &&
Local == other.Local &&
Expand Down
44 changes: 30 additions & 14 deletions Source/ChattelTests/TestStratusAsset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ public static void TestStratusAsset_ToWHIPSerialized_Correct() {

#endregion

#region Comparison
#region Equal(StratusAsset)

[Test]
public static void TestStratusAsset_Equals_Full_Equal() {
public static void TestStratusAsset_EqualsStratusAsset_Full_Equal() {
var asset1 = new StratusAsset {
CreateTime = DateTimeOffset.FromUnixTimeSeconds(1517468421).DateTime,
Data = new byte[] { 0, 1, 2, 3 },
Expand Down Expand Up @@ -108,7 +108,7 @@ public static void TestStratusAsset_Equals_Full_Equal() {
}

[Test]
public static void TestStratusAsset_Equals_NoData_Equal() {
public static void TestStratusAsset_EqualsStratusAsset_NoData_Equal() {
var asset1 = new StratusAsset {
CreateTime = DateTimeOffset.FromUnixTimeSeconds(1517468421).DateTime,
Description = "asdf",
Expand All @@ -134,7 +134,7 @@ public static void TestStratusAsset_Equals_NoData_Equal() {
}

[Test]
public static void TestStratusAsset_Equals_Bare_Equal() {
public static void TestStratusAsset_EqualsStratusAsset_Bare_Equal() {
var asset1 = new StratusAsset {
};
var asset2 = new StratusAsset {
Expand All @@ -144,7 +144,7 @@ public static void TestStratusAsset_Equals_Bare_Equal() {
}

[Test]
public static void TestStratusAsset_Equals_CreateTimeDiff_NotEqual() {
public static void TestStratusAsset_EqualsStratusAsset_CreateTimeDiff_NotEqual() {
var asset1 = new StratusAsset {
CreateTime = DateTimeOffset.FromUnixTimeSeconds(1517468421).DateTime,
Data = new byte[] { 0, 1, 2, 3 },
Expand Down Expand Up @@ -172,7 +172,7 @@ public static void TestStratusAsset_Equals_CreateTimeDiff_NotEqual() {
}

[Test]
public static void TestStratusAsset_Equals_DataDiff_NotEqual() {
public static void TestStratusAsset_EqualsStratusAsset_DataDiff_NotEqual() {
var asset1 = new StratusAsset {
CreateTime = DateTimeOffset.FromUnixTimeSeconds(1517468421).DateTime,
Data = new byte[] { 0, 1, 2, 3 },
Expand Down Expand Up @@ -200,7 +200,7 @@ public static void TestStratusAsset_Equals_DataDiff_NotEqual() {
}

[Test]
public static void TestStratusAsset_Equals_DataDiffNull_NotEqual() {
public static void TestStratusAsset_EqualsStratusAsset_DataDiffNull_NotEqual() {
var asset1 = new StratusAsset {
CreateTime = DateTimeOffset.FromUnixTimeSeconds(1517468421).DateTime,
Data = new byte[] { 0, 1, 2, 3 },
Expand Down Expand Up @@ -228,7 +228,7 @@ public static void TestStratusAsset_Equals_DataDiffNull_NotEqual() {
}

[Test]
public static void TestStratusAsset_Equals_DescriptionDiff_NotEqual() {
public static void TestStratusAsset_EqualsStratusAsset_DescriptionDiff_NotEqual() {
var asset1 = new StratusAsset {
CreateTime = DateTimeOffset.FromUnixTimeSeconds(1517468421).DateTime,
Data = new byte[] { 0, 1, 2, 3 },
Expand Down Expand Up @@ -256,7 +256,7 @@ public static void TestStratusAsset_Equals_DescriptionDiff_NotEqual() {
}

[Test]
public static void TestStratusAsset_Equals_IdDiff_NotEqual() {
public static void TestStratusAsset_EqualsStratusAsset_IdDiff_NotEqual() {
var asset1 = new StratusAsset {
CreateTime = DateTimeOffset.FromUnixTimeSeconds(1517468421).DateTime,
Data = new byte[] { 0, 1, 2, 3 },
Expand Down Expand Up @@ -284,7 +284,7 @@ public static void TestStratusAsset_Equals_IdDiff_NotEqual() {
}

[Test]
public static void TestStratusAsset_Equals_LocalDiff_NotEqual() {
public static void TestStratusAsset_EqualsStratusAsset_LocalDiff_NotEqual() {
var asset1 = new StratusAsset {
CreateTime = DateTimeOffset.FromUnixTimeSeconds(1517468421).DateTime,
Data = new byte[] { 0, 1, 2, 3 },
Expand Down Expand Up @@ -312,7 +312,7 @@ public static void TestStratusAsset_Equals_LocalDiff_NotEqual() {
}

[Test]
public static void TestStratusAsset_Equals_NameDiff_NotEqual() {
public static void TestStratusAsset_EqualsStratusAsset_NameDiff_NotEqual() {
var asset1 = new StratusAsset {
CreateTime = DateTimeOffset.FromUnixTimeSeconds(1517468421).DateTime,
Data = new byte[] { 0, 1, 2, 3 },
Expand Down Expand Up @@ -340,7 +340,7 @@ public static void TestStratusAsset_Equals_NameDiff_NotEqual() {
}

[Test]
public static void TestStratusAsset_Equals_StorageFlagsDiff_NotEqual() {
public static void TestStratusAsset_EqualsStratusAsset_StorageFlagsDiff_NotEqual() {
var asset1 = new StratusAsset {
CreateTime = DateTimeOffset.FromUnixTimeSeconds(1517468421).DateTime,
Data = new byte[] { 0, 1, 2, 3 },
Expand Down Expand Up @@ -368,7 +368,7 @@ public static void TestStratusAsset_Equals_StorageFlagsDiff_NotEqual() {
}

[Test]
public static void TestStratusAsset_Equals_TempDiff_NotEqual() {
public static void TestStratusAsset_EqualsStratusAsset_TempDiff_NotEqual() {
var asset1 = new StratusAsset {
CreateTime = DateTimeOffset.FromUnixTimeSeconds(1517468421).DateTime,
Data = new byte[] { 0, 1, 2, 3 },
Expand Down Expand Up @@ -396,7 +396,7 @@ public static void TestStratusAsset_Equals_TempDiff_NotEqual() {
}

[Test]
public static void TestStratusAsset_Equals_TypeDiff_NotEqual() {
public static void TestStratusAsset_EqualsStratusAsset_TypeDiff_NotEqual() {
var asset1 = new StratusAsset {
CreateTime = DateTimeOffset.FromUnixTimeSeconds(1517468421).DateTime,
Data = new byte[] { 0, 1, 2, 3 },
Expand Down Expand Up @@ -424,5 +424,21 @@ public static void TestStratusAsset_Equals_TypeDiff_NotEqual() {
}

#endregion

#region Equal(object)

// All attempts to test the positive Equals(object) code path with a StratusAsset cast to object never hit that method.
// Thus all I've got here is the negative case.

[Test]
public static void TestStratusAsset_EqualsObject_String_NotEqual() {
var asset1 = new StratusAsset {
};
var asset2 = "Not an asset.";

Assert.AreNotEqual(asset1, asset2);
}

#endregion
}
}

0 comments on commit cfca947

Please sign in to comment.