Why the below assertion is not working?
Code:
[Test]
public void CreateNewTemplateTest()
{
OnlineSignupModel model = new OnlineSignupModel
{
SalesRepId = 68,
PriceAdvanced = (decimal)22.33,
PriceComplete = (decimal)44.33,
PriceMvr = (decimal)6.33,
SetupFee = (decimal)2.33,
};
Assert.That(model, Has.Exactly(5).Items);
}
Error:
System.ArgumentException : The actual value must be an IEnumerable
Parameter name: actual
at NUnit.Framework.Constraints.ExactCountConstraint.ApplyTo[TActual](TActual actual)
at NUnit.Framework.Assert.That[TActual](TActual actual, IResolveConstraint expression, String message, Object[] args)
at NUnit.Framework.Assert.That[TActual](TActual actual, IResolveConstraint expression)
I am trying to assert that there are 5 properties in the object.
OnlineSignupModel
derive fromIEnumerable
?Has.Exactly
is for. Why would you even be testing for the existence of 5 properties? It's a class: you either defined the properties or you didn't. It seems like you are trying to test whether or not the properties were assigned to. That's still not a job forHas.Exactly
.