Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into AdvancedBeforeSeal
- Loading branch information
Showing
8 changed files
with
1,780 additions
and
1,743 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Should; | ||
using Xunit; | ||
using System.Linq; | ||
using AutoMapper; | ||
using AutoMapper.QueryableExtensions; | ||
|
||
namespace AutoMapper.UnitTests.Bug | ||
{ | ||
public class CannotProjectStringToNullableEnum | ||
{ | ||
public enum DummyTypes : int | ||
{ | ||
Foo = 1, | ||
Bar = 2 | ||
} | ||
|
||
public class DummySource | ||
{ | ||
public string Dummy { get; set; } | ||
} | ||
|
||
public class DummyDestination | ||
{ | ||
public DummyTypes? Dummy { get; set; } | ||
} | ||
|
||
[Fact] | ||
public void Should_project_string_to_nullable_enum() | ||
{ | ||
var config = new MapperConfiguration(cfg => | ||
{ | ||
cfg.CreateMap<string, DummyTypes?>().ProjectUsing(s => (DummyTypes)System.Enum.Parse(typeof(DummyTypes),s)); | ||
cfg.CreateMap<DummySource, DummyDestination>(); | ||
}); | ||
|
||
config.AssertConfigurationIsValid(); | ||
|
||
var src = new DummySource[] { new DummySource { Dummy = "Foo" } }; | ||
|
||
var destination = src.AsQueryable().ProjectTo<DummyDestination>(config).First(); | ||
|
||
destination.Dummy.ShouldEqual(DummyTypes.Foo); | ||
} | ||
} | ||
} |
Oops, something went wrong.