Skip to content

Instantly share code, notes, and snippets.

@mneedham
Created February 7, 2010 03:28
Show Gist options
  • Save mneedham/297177 to your computer and use it in GitHub Desktop.
Save mneedham/297177 to your computer and use it in GitHub Desktop.
[Test]
public void ShouldNotCopyTheId()
{
Mapper.Reset();
Mapper.CreateMap<Mark, Mark>();
Mapper.CreateMap<Foo, Foo>().ForMember(foo => foo.Id, opts => opts.Ignore());
var mark = new Mark { Foos = new List<Foo> { new Foo { Id = Guid.NewGuid()}}};
var newMark = Mapper.Map<Mark, Mark>(mark);
Assert.That(newMark.Foos[0].Id, Is.EqualTo(Guid.Empty));
}
public class Mark
{
public List<Foo> Foos { get; set; }
}
public class Foo
{
public Guid Id { get; set; }
}
NUnit.Framework.AssertionException: Expected: 00000000-0000-0000-0000-000000000000
But was: b94fb309-5af8-4740-984f-602cf6308c89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment