Created
April 6, 2016 18:34
-
-
Save christopherbauer/1da13483a2ab2fa48afd3174033ebf67 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| public class DataMapperTests | |
| { | |
| [TestFixture] | |
| public class WhenMap | |
| { | |
| internal class Source | |
| { | |
| public int id { get; set; } | |
| } | |
| internal class Destination | |
| { | |
| public int id { get; set; } | |
| } | |
| [SetUp] | |
| public void Setup() | |
| { | |
| Mapper.Reset(); | |
| } | |
| [Test] | |
| public void ThenShouldMapSourceTypeToDestinationTypeGivenConfigured() | |
| { | |
| // Arrange | |
| Mapper.CreateMap<Source, Destination>(); | |
| var mapper = new DataMapper(Mapper.Engine); | |
| //Act | |
| const int id = 1; | |
| var destination = mapper.Map<Destination>(new Source {id = id}); | |
| //Assert | |
| Assert.That(destination.id, Is.EqualTo(id)); | |
| } | |
| [Test] | |
| public void ThenShouldThrowAutoMapperMappingExceptionGivenNotConfigured() | |
| { | |
| // Arrange | |
| var mapper = new DataMapper(Mapper.Engine); | |
| var source = new Source { id = 1 }; | |
| //Act //Assert | |
| Assert.Throws<AutoMapperMappingException>(() => mapper.Map<Destination>(source)); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment