public void Static_Comparer_Configure_A_Type() { Comparer.Configure <HasIgnores>() .Ignore(x => x.IgnoreChild) .Ignore(x => x.IgnoreValue); var oldModel = new HasIgnores { Id = 1, IgnoreValue = 5, IgnoreChild = new GrandChildModel { Id = 10, Name = "A", Value = 100 } }; var newModel = new HasIgnores { Id = 2, IgnoreValue = 55, IgnoreChild = new GrandChildModel { Id = 20, Name = "B", Value = 200 } }; var comparer = Comparer.Get <HasIgnores>(); var changes = comparer(oldModel, newModel); Assert.AreEqual(changes.Count(), 1); Assert.IsNotNull(changes.Single(x => x.Name == "Id" && (long)x.OldValue == 1 && (long)x.NewValue == 2)); }
public void Compare_Object_With_Ignored_Properties() { SutEngine.Configure <HasIgnores>() .Ignore(x => x.IgnoreChild) .Ignore(x => x.IgnoreValue); var oldModel = new HasIgnores { Id = 1, IgnoreValue = 5, IgnoreChild = new GrandChildModel { Id = 10, Name = "A", Value = 100 } }; var newModel = new HasIgnores { Id = 2, IgnoreValue = 55, IgnoreChild = new GrandChildModel { Id = 20, Name = "B", Value = 200 } }; var changes = SutEngine.Compare(oldModel, newModel); Assert.AreEqual(changes.Count(), 1); Assert.IsNotNull(changes.Single(x => x.Name == "Id" && (long)x.OldValue == 1 && (long)x.NewValue == 2)); }
public void When_I_Ignore_A_Property_It_Should_Not_Test_It() { Comparer.Configure<HasIgnores>() .Ignore(x => x.IgnoreChild) .Ignore(x => x.IgnoreValue); var oldModel = new HasIgnores { Id = 1, IgnoreValue = 5, IgnoreChild = new GrandChildModel { Id = 10, Name = "A", Value = 100 } }; var newModel = new HasIgnores { Id = 2, IgnoreValue = 55, IgnoreChild = new GrandChildModel { Id = 20, Name = "B", Value = 200 } }; var changes = Comparer.Compare(oldModel, newModel); Assert.AreEqual(changes.Count(), 1); Assert.IsNotNull(changes.Single(x => x.Name == "Id" && (long)x.OldValue == 1 && (long)x.NewValue == 2)); }
public void Compare_Object_With_Ignored_Properties() { SutEngine.Configure<HasIgnores>() .Ignore(x => x.IgnoreChild) .Ignore(x => x.IgnoreValue); var oldModel = new HasIgnores { Id = 1, IgnoreValue = 5, IgnoreChild = new GrandChildModel { Id = 10, Name = "A", Value = 100 } }; var newModel = new HasIgnores { Id = 2, IgnoreValue = 55, IgnoreChild = new GrandChildModel { Id = 20, Name = "B", Value = 200 } }; var changes = SutEngine.Compare(oldModel, newModel); Assert.AreEqual(changes.Count(), 1); Assert.IsNotNull(changes.Single(x => x.Name == "Id" && (long)x.OldValue == 1 && (long)x.NewValue == 2)); }
public void Static_Comparer_Configure_A_Type() { Comparer.Configure<HasIgnores>() .Ignore(x => x.IgnoreChild) .Ignore(x => x.IgnoreValue); var oldModel = new HasIgnores { Id = 1, IgnoreValue = 5, IgnoreChild = new GrandChildModel { Id = 10, Name = "A", Value = 100 } }; var newModel = new HasIgnores { Id = 2, IgnoreValue = 55, IgnoreChild = new GrandChildModel { Id = 20, Name = "B", Value = 200 } }; var comparer = Comparer.Get<HasIgnores>(); var changes = comparer(oldModel, newModel); Assert.AreEqual(changes.Count(), 1); Assert.IsNotNull(changes.Single(x => x.Name == "Id" && (long)x.OldValue == 1 && (long)x.NewValue == 2)); }