-
Notifications
You must be signed in to change notification settings - Fork 23
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
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 throwDestination.OnlyInDestinationwill map toSource.OnlyInSourcebecause of theReverseMap()
Actual behavior
AssertConfigurationIsValid()throws- Trying to map
DestinationtoSourcethrows
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);
}
}Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request