Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Unit Test for Equals with structs #189

Merged
merged 3 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Tests/NFUnitTestStruct/UnitTestStructs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,21 @@ public void Structs55_Test()
Assert.True(StructsTestClass_55.testMethod());
}

[TestMethod]
public void ValueTest_StructEquals_01()
{
AStruct s1 = new AStruct() { a = 1 };
AStruct s2 = new AStruct() { a = 2 };

Assert.True(s1.Equals(s1), "Comparing struct failed: s1.Equals(s1)");
Assert.False(s1.Equals(s2), "Comparing struct failed: s1.Equals(s2)");
Assert.True(s1.a.Equals(s1.a), "Comparing struct failed: s1.a.Equals(s1.a)");
Assert.False(s1.a.Equals(s2.a), "Comparing struct failed: s1.a.Equals(s2.a)");
// TODO
// these are failing: need to fix the comparer at CLR
//Assert.False(s1.Equals(null), "Comparing struct failed: s1.Equals(null)");
//Assert.False(s1.Equals(null), "Comparing struct failed: s1.Equals(null)");
}

//Compiled Test Cases
class StructsTestClass_01_Notes
Expand Down Expand Up @@ -1031,6 +1046,9 @@ public static bool testMethod()
}
}


public struct AStruct
{
public int a { get; set; }
}
}
}
2 changes: 1 addition & 1 deletion Tests/NFUnitTest_DummyAdapter/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "Direct",
"requested": "[1.12.0, 1.12.0]",
"resolved": "1.12.0",
"contentHash": "ls2oi2tgc511yCRrbBOD3KjS9AL4mIWwEs6/g3DuLhGpALhla/g1Dr9qry69M3NwEWEY3rSolxIiwueeqepckQ=="
"contentHash": "qQrFNXmJiStMC4VXk5cVMOJp23/qlT9FW5i9i+igwQVwraQTtvpkam8yK1hj992jqrbjoCIFZP4Hw9E8H0pB7w=="
},
"nanoFramework.TestFramework": {
"type": "Direct",
Expand Down