private static ICoffeeMapper CreateMapperWithExampleMapping() { ClassMappingInstructionHolder mappingInstructions = new ClassMappingInstructionHolder(); mappingInstructions.AddMapping <ExampleClass1, ExampleClass2>(); ICoffeeMapper mapper = new CoffeeMapper(mappingInstructions); return(mapper); }
public void ClassMappingAutoDiscoversBasicPropertyFromIntToLong() { ClassMappingInstructionHolder mappingInstructions = new ClassMappingInstructionHolder(); mappingInstructions.AddMapping <ExampleClassWithIntProperty, ExampleClassWithLongProperty>(); ICoffeeMapper mapper = new CoffeeMapper(mappingInstructions); ExampleClassWithIntProperty exampleObject1 = GetExampleObjectWithIntProperty(); ExampleClassWithLongProperty result = mapper.Map <ExampleClassWithLongProperty>(exampleObject1); Assert.AreEqual(exampleObject1.A, result.A); }
public void ClassMappingAutoDiscoversBasicPropertyWithMismatchTypes() { ClassMappingInstructionHolder mappingInstructions = new ClassMappingInstructionHolder(); mappingInstructions.AddMapping <ExampleClass1, ExampleClassWithIntProperty>(new ClassMappingInstructionOptions { AutoAddPropertiesWithSameName = true }); ICoffeeMapper mapper = new CoffeeMapper(mappingInstructions); ExampleClass1 exampleObject1 = GetObject1(); ExampleClassWithIntProperty result = mapper.Map <ExampleClassWithIntProperty>(exampleObject1); Assert.AreEqual(exampleObject1.A, result.A); }
public void ClassMappingWithoutAutoDiscoversBasicProperty() { ClassMappingInstructionHolder mappingInstructions = new ClassMappingInstructionHolder(); mappingInstructions.AddMapping <ExampleClass1, ExampleClass2>(new ClassMappingInstructionOptions { AutoAddPropertiesWithSameName = false }); ICoffeeMapper mapper = new CoffeeMapper(mappingInstructions); ExampleClass1 exampleObject1 = GetObject1(); ExampleClass2 result = mapper.Map <ExampleClass2>(exampleObject1); Assert.AreEqual(null, result.A); }