public void auto_attribute_type_should_work_using_two_way_aspect_with_multiple_types() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var mapper = The <IObjectMapper>(); var myclass = new MyClassTwoWayMultipleTypes { TestProperty = "Oguzhan" }; //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- MyClassDto mappedObject = mapper.Map(myclass, new MyClassDto()); MyClassDto2 mappedObject2 = mapper.Map(myclass, new MyClassDto2()); MyClassTwoWayMultipleTypes twoWayMappedObject = mapper.Map(mappedObject, new MyClassTwoWayMultipleTypes()); MyClassTwoWayMultipleTypes twoWayMappedObject2 = mapper.Map(mappedObject2, new MyClassTwoWayMultipleTypes()); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- mappedObject.ShouldNotBeNull(); mappedObject.TestProperty.ShouldBe("Oguzhan"); twoWayMappedObject.ShouldNotBeNull(); twoWayMappedObject.TestProperty.ShouldBe("Oguzhan"); mappedObject2.ShouldNotBeNull(); mappedObject2.TestProperty.ShouldBe("Oguzhan"); twoWayMappedObject2.ShouldNotBeNull(); twoWayMappedObject2.TestProperty.ShouldBe("Oguzhan"); }
public void auto_attribute_type_should_work_with_multiple_attributes_when_TSource_and_TDestination_provided() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var mapper = The <IObjectMapper>(); var myclass = new MyClassWithMultipleAttribute { TestProperty = "Oguzhan" }; //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- MyClassDto mappedObject1 = mapper.Map(myclass, new MyClassDto()); MyClassDto2 mappedObject2 = mapper.Map(myclass, new MyClassDto2()); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- mappedObject1.ShouldNotBeNull(); mappedObject2.ShouldNotBeNull(); mappedObject1.TestProperty.ShouldBe("Oguzhan"); mappedObject2.TestProperty.ShouldBe("Oguzhan"); }
public void auto_attibute_mapping_should_work_when_only_TDestination_and_TSource_provided() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var mapper = The <IObjectMapper>(); var myclass = new MyClass { TestProperty = "Oguzhan" }; //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- MyClassDto mappedObject = mapper.Map(myclass, new MyClassDto()); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- mappedObject.TestProperty.ShouldNotBeNull(); mappedObject.TestProperty.ShouldBe("Oguzhan"); }
public void mapping_should_work_with_extensions() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var myclass = new MyClass { TestProperty = "Oguzhan" }; var myclassDto = new MyClassDto(); //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- var mappedObject = myclass.MapTo <MyClassDto>(); MyClassDto mappedObject2 = myclass.MapTo(myclassDto); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- mappedObject.ShouldNotBeNull(); mappedObject.TestProperty.ShouldBe("Oguzhan"); mappedObject2.ShouldNotBeNull(); mappedObject2.TestProperty.ShouldBe("Oguzhan"); }
public void auto_attribute_type_should_work_with_multiple_attributes_using_to_aspect() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var mapper = The <IObjectMapper>(); var myclassDto = new MyClassDto { TestProperty = "Oguzhan" }; //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- var mappedObject1 = mapper.Map <MyClassToAspect1>(myclassDto); var mappedObject2 = mapper.Map <MyClassToAspect2>(myclassDto); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- mappedObject1.ShouldNotBeNull(); mappedObject1.TestProperty.ShouldBe("Oguzhan"); mappedObject2.ShouldNotBeNull(); mappedObject2.TestProperty.ShouldBe("Oguzhan"); }
public static MyClass FromMyClassDto(MyClassDto myClassDto) { return(AutoMapper.LoadEntityFromDto <MyProject.DTO.MyClassDto, MyClass>(myClassDto)); }