试图理解verifySet等的使用......但除非我做一个解决方法,否则我无法让它工作.
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());
}
Run Code Online (Sandbox Code Playgroud)
有人可以澄清我应该如何在属性上使用VerifySet和Verify和VerifyGet?我很困惑.