public static void AssertIsEqual(ModelWithFieldsOfNullableTypes actual, ModelWithFieldsOfNullableTypes expected)
{
Assert.That(actual.Id, Is.EqualTo(expected.Id));
Assert.That(actual.NId, Is.EqualTo(expected.NId));
Assert.That(actual.NGuid, Is.EqualTo(expected.NGuid));
Assert.That(actual.NLongId, Is.EqualTo(expected.NLongId));
Assert.That(actual.NBool, Is.EqualTo(expected.NBool));
Assert.That(actual.NTimeSpan, Is.EqualTo(expected.NTimeSpan));
try
{
Assert.That(actual.NDateTime, Is.EqualTo(expected.NDateTime));
}
catch (Exception ex)
{
Log.Error("Trouble with DateTime precisions, trying Assert again with rounding to seconds", ex);
Assert.That(actual.NDateTime.Value.ToUniversalTime().RoundToSecond(), Is.EqualTo(expected.NDateTime.Value.ToUniversalTime().RoundToSecond()));
}
try
{
Assert.That(actual.NFloat, Is.EqualTo(expected.NFloat));
}
catch (Exception ex)
{
Log.Error("Trouble with float precisions, trying Assert again with rounding to 10 decimals", ex);
Assert.That(Math.Round(actual.NFloat.Value, 10), Is.EqualTo(Math.Round(actual.NFloat.Value, 10)));
}
try
{
Assert.That(actual.NDouble, Is.EqualTo(expected.NDouble));
}
catch (Exception ex)
{
Log.Error("Trouble with double precisions, trying Assert again with rounding to 10 decimals", ex);
Assert.That(Math.Round(actual.NDouble.Value, 10), Is.EqualTo(Math.Round(actual.NDouble.Value, 10)));
}
}
}