public static void AssertIsEqual(ModelWithFieldsOfDifferentTypes actual, ModelWithFieldsOfDifferentTypes expected) { Assert.That(actual.Id, Is.EqualTo(expected.Id)); Assert.That(actual.Name, Is.EqualTo(expected.Name)); Assert.That(actual.Guid, Is.EqualTo(expected.Guid)); Assert.That(actual.LongId, Is.EqualTo(expected.LongId)); Assert.That(actual.Bool, Is.EqualTo(expected.Bool)); try { Assert.That(actual.DateTime, Is.EqualTo(expected.DateTime)); } catch (Exception ex) { Log.Error("Trouble with DateTime precisions, trying Assert again with rounding to seconds", ex); Assert.That(actual.DateTime.RoundToSecond(), Is.EqualTo(expected.DateTime.RoundToSecond())); } try { Assert.That(actual.Double, Is.EqualTo(expected.Double)); } catch (Exception ex) { Log.Error("Trouble with double precisions, trying Assert again with rounding to 10 decimals", ex); Assert.That(Math.Round(actual.Double, 10), Is.EqualTo(Math.Round(actual.Double, 10))); } }
public static ModelWithFieldsOfDifferentTypes Create(int id) { var row = new ModelWithFieldsOfDifferentTypes { Id = id, Bool = id % 2 == 0, DateTime = DateTime.Now.AddDays(id), Double = 1.11d + id, Guid = Guid.NewGuid(), LongId = 999 + id, Name = "Name" + id }; return row; }