在VSTO ContactItem上使用Moq时,我收到以下错误:
variable 'x' of type 'Microsoft.Office.Interop.Outlook.ContactItem' referenced from scope '', but it is not defined
代码如下:
public class ContactItemTests
{
private Mock<ContactItem> _contactItemMock;
[SetUp]
public void Init()
{
_contactItemMock = new Mock<ContactItem>();
}
[Test]
public void MyTest()
{
var firstName= _contactItemMock.Setup(x => x.FirstName).Returns("Don");
var userProperty = _contactItemMock.Setup(x => x.UserProperties.Find("Test",null)).Returns(()=>null);
Assert.IsTrue(userProperty == null);
}
}
我的问题是:
为什么VS 2017找不到UserProperties属性?
答案 0 :(得分:0)
UserProperties是另一个需要设置的对象。