Esempio n. 1
0
        public void NoMappingFoundException()
        {
            ClassMappingInstructionHolder mappingInstructions = new ClassMappingInstructionHolder();
            ICoffeeMapper mapper         = new CoffeeMapper(mappingInstructions);
            ExampleClass1 exampleObject1 = GetObject1();

            Assert.ThrowsException <NoMappingFoundException>
                (() => mapper.Map <ExampleClass2>(exampleObject1));
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }