I have a simple unit test which tests that a validation function picks up a specific validation issue. The validation item returns a simple object with Item & Message properties. I've written a unit test for this function but this always fails even though I know the function works as expected.
<TestMethod()> Public Sub ContractNote_ValidateForManualInputTest_TradeOrderValueComparison()
'Can't get this test to work even though validation works!
Dim CN As ContractNote = New ContractNote
Dim Trade As New TradeOrder
Trade.TradeValue = 100
With CN
.CNTradeDate = Date.Today
.CNTradePrice = 1
.CNTradeUnits = 1
.CNTradeValue = 1
.FundManagerReference = "_zzz_"
.SkandiaCompanyOrderID = "xxx"
.ParentTradeOrder = Trade
End With
Dim ActualItems As System.Collections.Generic.List(Of ValidationItem) = CN.ValidateForManualInput
If actualitems.Count > 0 Then
Dim item As ValidationItem = New ValidationItem("Value", "Must match trade value")
CollectionAssert.Contains(ActualItems, item, "")
End If
Assert.AreNotEqual(0, ActualItems.Count)
End Sub
I've implemented IComparable on ValidationItem (I have a separate unit test which confirms this works). Am I Using CollectionAssert correctly?