I am using Automapper 6.2.1 and by that removed all statics and instead I am injecting IMapper
.
I am using NSubstitute for mocking.
I have a bit of code where I map two existing objects.
public class Person1 {
public string Value1 { get; set; }
public string Value2 { get; set; }
}
public class Person2 {
public string Value2 { get; set; }
}
...
_mapper.Map(person2, person1);
My mapping will replace Value2
in person1
.
I am thereafter using person1
with the modified value.
Is it possible to "return" a different person1 from my mock? And how can I do that, if possible?
EDIT
Yes, my question is how I can mock my _mapper
correctly and "return" a different person1 (by ref) using NSubstitute.
person1 is a reference object meaning that in the real implementation Value2 from person2 will replace Value2 in person1. But in my unit test I failed to simulate this scenario.