I use NSubstitute a lot. And I love it.
I am just looking into AutoFixture. It seems great!
I have seen AutoFixture for NSubstitute and seen a few examples in Moq on how to use this feature.
But I can't seem to translate it into NSubstitute.
I tried this:
var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
var addDest = Substitute.For<IPerson>();
Using:
public interface IPersonEntity
{
int ID { get; set; }
string FirstName { get; set;}
string LastName { get; set;}
DateTime DateOfBirth { get; set; }
char Gender { get; set; }
}
And I get an object, but none of the properties are populated (kind of the point of AutoFixture).
I also tried:
var fixture = new Fixture().Customize(new AutoNSubstituteCustomization());
var result = fixture.Create<IPersonEntity>();
That also gave me an object with no populated properties. (Note if I do the above with a PersonEntity
class, then the properties are all populated.)
I am sure that there is a way to make this work, but I can't seem to find it.
So, given my IPersonEntity
interface above, does anyone know how to use AutoFixture and NSubstitute to give me a populated IPersonEntity object?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…