本文整理汇总了C#中System.Property.GetIdValue方法的典型用法代码示例。如果您正苦于以下问题:C# Property.GetIdValue方法的具体用法?C# Property.GetIdValue怎么用?C# Property.GetIdValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Property
的用法示例。
在下文中一共展示了Property.GetIdValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetIdValue_WhenNullAssignedNullableIntOnFirstLevel_ReturnsInt
public void GetIdValue_WhenNullAssignedNullableIntOnFirstLevel_ReturnsInt()
{
var intPropertyInfo = typeof(Dummy2).GetProperty("NullableId");
var intProperty = new Property(intPropertyInfo);
var item = new Dummy2 { NullableId = null };
var actual = intProperty.GetIdValue<Dummy2, int>(item);
Assert.IsNull(actual);
}
示例2: GetIdValue_WhenNullableIntOnFirstLevel_ReturnsInt
public void GetIdValue_WhenNullableIntOnFirstLevel_ReturnsInt()
{
var intPropertyInfo = typeof(Dummy2).GetProperty("NullableId");
var intProperty = new Property(intPropertyInfo);
const int expectedInt = 42;
var item = new Dummy2 { NullableId = expectedInt };
var actual = intProperty.GetIdValue<Dummy2, int>(item);
Assert.AreEqual(expectedInt, actual);
}
示例3: GetIdValue_WhenNullableGuidOnFirstLevel_ReturnsGuid
public void GetIdValue_WhenNullableGuidOnFirstLevel_ReturnsGuid()
{
var intPropertyInfo = typeof(Dummy2).GetProperty("NullableId");
var intProperty = new Property(intPropertyInfo);
var expected = Guid.Parse("4217F3B7-6DEB-4DFA-B195-D111C1297988");
var item = new Dummy2 { NullableId = expected };
var actual = intProperty.GetIdValue<Dummy2, Guid>(item);
Assert.AreEqual(expected, actual);
}
示例4: GetIdValue_WhenIntNotOnFirstLevel_ThrowsSisoDbException
public void GetIdValue_WhenIntNotOnFirstLevel_ThrowsSisoDbException()
{
var dummy2PropertyInfo = typeof(Dummy1).GetProperty("Item");
var dummy2Property = new Property(dummy2PropertyInfo);
var intPropertyInfo = typeof(Dummy2).GetProperty("Id");
var intProperty = new Property(1, dummy2Property, intPropertyInfo);
var item = new Dummy1 { Item = new Dummy2 { Id = 42 } };
var ex = Assert.Throws<SisoDbException>(() => intProperty.GetIdValue<Dummy1, int>(item));
Assert.AreEqual(ExceptionMessages.Property_GetIdValue_InvalidLevel, ex.Message);
}
示例5: GetIdValue_WhenGuidNotOnFirstLevel_ThrowsSisoDbException
public void GetIdValue_WhenGuidNotOnFirstLevel_ThrowsSisoDbException()
{
var dummy2PropertyInfo = typeof (Dummy1).GetProperty("Item1");
var dummy2Property = new Property(dummy2PropertyInfo);
var guidPropertyInfo = typeof(Dummy2).GetProperty("Id");
var guidProperty = new Property(1, dummy2Property,guidPropertyInfo);
var item = new Dummy1 { Item1 = new Dummy2 { Id = Guid.NewGuid() } };
var ex = CustomAssert.Throws<SisoDbException>(() => guidProperty.GetIdValue<Dummy1, Guid>(item));
Assert.AreEqual(ExceptionMessages.Property_GetIdValue_InvalidLevel, ex.Message);
}