Skip to content

Instantly share code, notes, and snippets.

@samueleresca
Created December 3, 2015 20:50
Show Gist options
  • Save samueleresca/16806de354edbe3d0281 to your computer and use it in GitHub Desktop.
Save samueleresca/16806de354edbe3d0281 to your computer and use it in GitHub Desktop.
Imports NUnit
Imports NUnit.Framework
Public Class AnonymousTypeTests
<TestMethod()>
<TestCase(Description:="Compare two anonymous obj with the same values", _ ExpectedMessage:="The two objects are NOT EQUAL")>
Public Sub Compare_Anonymous_Objects()
Assert.AreEqual(New With {.Value = 0, .Description = "Male"}, _
New With {.Value = 0, .Description = "Male"})
End Sub
<TestMethod()>
<TestCase(Description:="Compare the type of two anonymous obj", _ ExpectedMessage:="The two types are EQUAL")>
Public Sub Compare_Anonymous_Objects_Type()
Assert.AreEqual(New With {.Value = 0, .Description = "Male"}.GetType(), _
New With {.Value = 0, .Description = "Male"}.GetType())
End Sub
<TestMethod()>
<TestCase(Description:="Compare two anonymous obj with same values using KEY property", _ ExpectedMessage:="The two objects are EQUAL equal")>
Public Sub Compare_Anonymous_Objects_Using_Key_On_Value()
Assert.AreEqual(New With {Key .Value = 0, .Description = "Male"}, _
New With {Key .Value = 0, .Description = "Male"})
End Sub
<TestMethod()>
<TestCase(Description:="Compare two anonymous obj with different values using KEY property", _ ExpectedMessage:="The two objects are EQUAL")>
Public Sub Compare_Anonymous_Objects_With_Different_Descriptions_Values_Using_Key_On_Value()
Assert.AreEqual(New With {Key .Value = 0, .Description = "Male"}, _
New With {Key .Value = 0, .Description = "Female"})
End Sub
<TestMethod()>
<TestCase(Description:="Compare two anonymous object with different values using KEY property on both attributes", _ ExpectedMessage:="The two objects are NOT EQUAL")>
Public Sub Compare_Anonymous_Objects_With_Different_Values_Using_Key_On_Value_And_Description()
Assert.AreEqual(New With {Key .Value = 0, Key .Description = "Male"}, _
New With {Key .Value = 0, Key .Description = "Female"})
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment