本文整理汇总了C#中MockPropertyInfo.Setup方法的典型用法代码示例。如果您正苦于以下问题:C# MockPropertyInfo.Setup方法的具体用法?C# MockPropertyInfo.Setup怎么用?C# MockPropertyInfo.Setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MockPropertyInfo
的用法示例。
在下文中一共展示了MockPropertyInfo.Setup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsValidStructuralProperty_should_return_false_for_indexed_property
public void IsValidStructuralProperty_should_return_false_for_indexed_property()
{
var mockProperty = new MockPropertyInfo();
mockProperty.Setup(p => p.GetIndexParameters()).Returns(new ParameterInfo[1]);
Assert.False(mockProperty.Object.IsValidStructuralProperty());
}
示例2: CreatePropertySetter_throws_for_pointer_types
public void CreatePropertySetter_throws_for_pointer_types()
{
var pointerType = new MockType();
pointerType.Protected().Setup<bool>("IsPointerImpl").Returns(true);
var property = new MockPropertyInfo(pointerType.Object, "PointerProp");
var setter = new Mock<MethodInfo>();
setter.Setup(m => m.ReturnType).Returns(pointerType.Object);
setter.Setup(m => m.DeclaringType).Returns(new MockType().Object);
property.Setup(m => m.GetSetMethod(true)).Returns(setter.Object);
Assert.Equal(
Strings.CodeGen_PropertyUnsupportedType,
Assert.Throws<InvalidOperationException>(
() => DelegateFactory.CreatePropertySetter(new MockType(), property.Object, true)).Message);
}