I'm new to Pex and Moles and i want to make use of parametrized unit tests. I am using constructor injection and I want to create a moles stub for my parameter.
public UserLogic(IUserRepository userRepository)
{
_userRepository = userRepository;
}
The documentation Ive read says Moles will generate a stub type for my repository of SIUserRepository. But I cant figure out how to generate the stub. Would anyone be able to provide an example. Thanks
I'll assume you haven't gotten as far as creating a Moles assembly yet. Here's some basic steps to follow;
Now, in some UserLogic_Test method, you can refer to the stub like so;
[TestMethod]
public void UserLogic_Test()
{
MyAssembly.SomeNameSpace.Moles.SUserRepository mock = new SUserRepository();
UserLogic o = new UserLogic(mock);
Assert.AreEqual(1, o.SomeMethod());
}