Hi all Beginner in Moq. Trying to understand the use of verifySet etc... but unless I do a workaround I cannot get it to work.
public interface IProduct
{
int Id { get; set; }
string Name { get; set; }
}
public void Can_do_something()
{
var newProduct = new Mock<IProduct>();
newProduct.SetupGet(p => p.Id).Returns(1);
newProduct.SetupGet(p => p.Name).Returns("Jo");
//This fails!! why is it because I have not invoked it
newProduct.VerifySet(p => p.Name, Times.AtLeastOnce());
//if I do this it works
newProduct.Object.Name = "Jo";
newProduct.VerifySet(p => p.Name, Times.AtLeastOnce());
}
Can somebody clarify how I should use VerifySet and Verify and VerifyGet on a property? I am getting confused.
Thanks a lot