I'd like to ask you a question about AutoMapper. We are unit testing our mapping like that:
var dtoFiltrePersonne = new DtoFiltrePersonne { Prop1 = "Test", Prop2 = 1234 }; Mapper.CreateMap<FiltrePersonne, DtoFiltrePersonne>(); var filtrePersonne = DtoAutoMappeur<DtoFiltrePersonne, FiltrePersonne>.Instance.MapFromDtoToEntity(dtoFiltrePersonne); Assert.AreEqual(dtoFiltrePersonne.Prop1, filtrePersonne.Prop1); Assert.AreEqual(dtoFiltrePersonne.Prop2, filtrePersonne.Prop2);
I'd like to know if this unit test provides the same coverage?
Mapper.CreateMap<FiltrePersonne, DtoFiltrePersonne>(); AutoMapper.AssertConfigurationIsValid()
I looked into the AutoMapper Configuration documentation and it's not pretty clear for me. Do I need to unit test each mapping or just use the AssertConfigurationIsValid
method?
It says:
Executing this code produces an AutoMapperConfigurationException, with a descriptive message. AutoMapper checks to make sure that every single Destination type member has a corresponding type member on the source type.
Every single member has correlation with destination type. It may not be the right one (since there are always exception cases), but it at least tests that every property is moved from source type to destination.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With