本文整理汇总了C#中MockPropertyInfo.SetupGet方法的典型用法代码示例。如果您正苦于以下问题:C# MockPropertyInfo.SetupGet方法的具体用法?C# MockPropertyInfo.SetupGet怎么用?C# MockPropertyInfo.SetupGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MockPropertyInfo
的用法示例。
在下文中一共展示了MockPropertyInfo.SetupGet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsValidStructuralProperty_should_return_true_when_property_read_only_collection
public void IsValidStructuralProperty_should_return_true_when_property_read_only_collection()
{
var mockProperty = new MockPropertyInfo(typeof(List<string>), "P");
mockProperty.SetupGet(p => p.CanWrite).Returns(false);
Assert.True(mockProperty.Object.IsValidStructuralProperty());
}
示例2: IsValidStructuralProperty_should_return_false_when_property_read_only
public void IsValidStructuralProperty_should_return_false_when_property_read_only()
{
var mockProperty = new MockPropertyInfo();
mockProperty.SetupGet(p => p.CanWrite).Returns(false);
Assert.False(mockProperty.Object.IsValidStructuralProperty());
}
示例3: AddComplexProperty_ThrowsIfTypeIsDateTime
public void AddComplexProperty_ThrowsIfTypeIsDateTime(Type propertyType)
{
// Arrange
MockType type = new MockType("Customer", @namespace: "Contoso");
MockPropertyInfo property = new MockPropertyInfo(propertyType, "Birthday");
property.SetupGet(p => p.ReflectedType).Returns(type);
property.SetupGet(p => p.DeclaringType).Returns(type);
Mock<StructuralTypeConfiguration> mock = new Mock<StructuralTypeConfiguration> { CallBase = true };
StructuralTypeConfiguration configuration = mock.Object;
mock.SetupGet(c => c.ClrType).Returns(type);
// Act & Assert
Assert.ThrowsArgument(
() => configuration.AddComplexProperty(property),
"propertyInfo",
string.Format(
"The type '{0}' of property 'Birthday' in the 'Contoso.Customer' type is not a supported type.",
propertyType.FullName));
}