本文整理汇总了C#中System.TestClass.GetPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:C# TestClass.GetPropertyValue方法的具体用法?C# TestClass.GetPropertyValue怎么用?C# TestClass.GetPropertyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.TestClass
的用法示例。
在下文中一共展示了TestClass.GetPropertyValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPropertyValue_InvalidPropertyName
public void GetPropertyValue_InvalidPropertyName()
{
var test = new TestClass() { BoolProperty = true, IntProperty = 42, StringProperty = "muh" };
Assert.That(() => test.GetPropertyValue<int>("TestProperty"), Throws.InstanceOf<ArgumentOutOfRangeException>());
}
示例2: GetPropertyValue
public void GetPropertyValue()
{
var test = new TestClass() { BoolProperty = true, IntProperty = 42, StringProperty = "muh" };
Assert.That(test.GetPropertyValue<int>("IntProperty"), Is.EqualTo(test.IntProperty));
Assert.That(test.GetPropertyValue<bool>("BoolProperty"), Is.EqualTo(test.BoolProperty));
Assert.That(test.GetPropertyValue<string>("StringProperty"), Is.EqualTo(test.StringProperty));
Assert.That(() => obj.GetPropertyValue<string>("StringProperty"), Throws.InstanceOf<NotImplementedException>());
}