public void CoreTestSimpleObjectWithExclude() { var source = MultipleSets.Create(5); var myDTO = Mapper.MapExclude <MultipleSets, DTO.MultipleSets>(source, x => x.SimpleClasses.Select(y => y.IntArray)); var manual = new DTO.MultipleSets(source); manual.SimpleClasses.ForEach(x => x.IntArray = null); Assert.Equal(myDTO, manual); }
public void CoreTestSimpleObjectWithNoInclude() { var source = MultipleSets.Create(5); var myDTO = Mapper.Map <MultipleSets, DTO.MultipleSets>(source, null); var manual = new DTO.MultipleSets() { Id = source.Id }; Assert.Equal(myDTO, manual); }
public void CoreTestSimpleObjectWithInclude() { var source = MultipleSets.Create(5); var myDTO = Mapper.Map <MultipleSets, DTO.MultipleSets>(source, x => x.SimpleClasses.Select(y => y.IntArray), x => x.IntegerSet); var manual = new DTO.MultipleSets() { Id = source.Id, IntegerSet = new HashSet <int>(source.IntegerSet), SimpleClasses = source.SimpleClasses.Select(p => { var res = new DTO.SimpleClass(p); res.VerySimpleClass = null; return(res); }).ToList() }; Assert.Equal(myDTO, manual); }
static void Main(string[] args) { Init.InitHMapper(); Init.InitAutomapper(); Init.InitExpressMapper(); var test = AutoMapper.Mapper.Map <PolymorphicSubClass, DTO.PolymorphicSubClass>(PolymorphicSubClass.Create(5)); Run("Very simple class", VerySimpleClass.CreateMany(300000), x => new DTO.VerySimpleClass(x)); Run("Simple class", SimpleClass.CreateMany(40000), x => new DTO.SimpleClass(x)); Run("Simple set", SimpleSet.CreateMany(10000, 100), x => new DTO.SimpleSet(x)); Run("Multiple set", MultipleSets.CreateMany(1000, 100), x => new DTO.MultipleSets(x)); Run("Dictionary", DictionarySet.CreateMany(300, 100), x => new DTO.DictionarySet(x)); Run("Simple generic class of int", SimpleGeneric <int> .CreateMany(Enumerable.Range(1, 300000).Select(i => i).ToArray()), x => new DTO.SimpleGeneric <int>(x)); Run("Mapped object generic class", MappedObjectGeneric <VerySimpleClass> .CreateMany(VerySimpleClass.CreateMany(200000)), x => new DTO.MappedObjectGeneric <DTO.VerySimpleClass>(x)); Run("Multiple generic class", MultipleGenerics <int, string> .CreateMany(Enumerable.Range(1, 200000).Select(i => Tuple.Create(i, Guid.NewGuid().ToString())).ToArray()), x => new DTO.MultipleGenerics <string, int>(x)); Run("Polymorphic class", PolymorphicSubSubClass.CreateMany(300000), x => new DTO.PolymorphicSubClass(x)); Run("Set of polymorphic class", SetOfPolymorphic.CreateMany(150000), x => new DTO.SetOfPolymorphic(x)); Run("Generic of polymorphic class", MappedObjectGeneric <PolymorphicBaseClass> .CreateMany(PolymorphicBaseClass.CreateMany(200000)), x => new DTO.MappedObjectGeneric <DTO.PolymorphicBaseClass>(x)); Run("Set of generic polymorphic classes", SetOfGenericPolymorph.CreateMany(50000), x => new DTO.SetOfGenericPolymorph(x)); }
public void CoreTestMultipleCollections() { Run(MultipleSets.Create(3), x => new DTO.MultipleSets(x)); }
public void TestMultipleCollections() { var tmp = Mapper.Map <int, int>(5); Run(MultipleSets.Create(1), x => new DTO.MultipleSets(x)); }