public void TestCompareIdenticalModels() { var modelA = new FlatModel { IntValue = 5, StringValue = "Hello" }; var modelB = new FlatModel { IntValue = 5, StringValue = "Hello" }; var comparer = new ObjectComparerFactory().Create <FlatModel>().All().Build(); var result = comparer.AreEqual(modelA, modelB); Assert.IsTrue(result); }
public void TestCompareDifferentModelsExcludeSubmodelProperty() { var modelA = new CompositeModel { IntValue = 5, SubmodelValue = new Submodel { StringValue = "Hello" } }; var modelB = new CompositeModel { IntValue = 5, SubmodelValue = new Submodel { StringValue = "Bye" } }; var result = new ObjectComparerFactory().Create <CompositeModel>().All() .Include(v => v.SubmodelValue, new ObjectComparerFactory().Create <Submodel>().All().Exclude(x => x.StringValue).Build()) .Build().AreEqual(modelA, modelB); Assert.IsTrue(result); }
protected IObjectComparer GetComparer() { var factory = new ObjectComparerFactory(); return(factory.Create <CompositeCollectionsModel>().All().Build()); }