Source/destination types
public enum Source { Default, OnlyInSource = 3 }
public enum Destination { Default, OnlyInDestination = 4}
Mapping configuration
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByValue()
.MapValue(Source.OnlyInSource, Destination.OnlyInDestination))
.ReverseMap();
Version: 3.2.0
Expected behavior
AssertConfigurationIsValid() doesn't throw
Destination.OnlyInDestination will map to Source.OnlyInSource because of the ReverseMap()
Actual behavior
AssertConfigurationIsValid() throws
- Trying to map
Destination to Source throws
In both cases the error is:
AutoMapper.AutoMapperMappingException : Value OnlyInDestination of type AutoMapper.Extensions.EnumMapping.Tests.ReverseCustomEnumValueMappingByValue+OnlyInSourceValueIsMappedToOnlyInDestiationValue+Destination not supported
Steps to reproduce
// This slightly altered test from the project's test suite will fail
public class OnlyInSourceValueIsMappedToOnlyInDestinationValue : AutoMapperSpecBase
{
readonly List<Source> _results = new List<Source>();
public enum Source { Default, OnlyInSource = 3 }
public enum Destination { Default, OnlyInDestination = 4}
protected override MapperConfiguration Configuration { get; } = new MapperConfiguration(cfg =>
{
cfg.EnableEnumMappingValidation();
cfg.CreateMap<Source, Destination>()
.ConvertUsingEnumMapping(opt => opt.MapByValue()
.MapValue(Source.OnlyInSource, Destination.OnlyInDestination))
.ReverseMap();
});
protected override void Because_of()
{
_results.Add(Mapper.Map<Destination, Source>(Destination.Default));
_results.Add(Mapper.Map<Destination, Source>(Destination.OnlyInDestination));
}
[Fact]
public void Should_map_using_custom_map()
{
_results[0].ShouldBe(Source.Default);
_results[1].ShouldBe(Source.OnlyInSource);
}
}
Source/destination types
Mapping configuration
Version: 3.2.0
Expected behavior
AssertConfigurationIsValid()doesn't throwDestination.OnlyInDestinationwill map toSource.OnlyInSourcebecause of theReverseMap()Actual behavior
AssertConfigurationIsValid()throwsDestinationtoSourcethrowsIn both cases the error is:
Steps to reproduce