Skip to content

Instantly share code, notes, and snippets.

@christopherbauer
Created April 6, 2016 18:34
Show Gist options
  • Select an option

  • Save christopherbauer/1da13483a2ab2fa48afd3174033ebf67 to your computer and use it in GitHub Desktop.

Select an option

Save christopherbauer/1da13483a2ab2fa48afd3174033ebf67 to your computer and use it in GitHub Desktop.
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