當前位置: 首頁>>代碼示例>>C#>>正文


C# Property.GetIdValue方法代碼示例

本文整理匯總了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);
        }
開發者ID:darrencauthon,項目名稱:SisoDb-Provider,代碼行數:11,代碼來源:PropertyGetIntValuesTests.cs

示例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);
        }
開發者ID:darrencauthon,項目名稱:SisoDb-Provider,代碼行數:12,代碼來源:PropertyGetIntValuesTests.cs

示例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);
        }
開發者ID:darrencauthon,項目名稱:SisoDb-Provider,代碼行數:12,代碼來源:PropertyGetGuidValuesTests.cs

示例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);
        }
開發者ID:darrencauthon,項目名稱:SisoDb-Provider,代碼行數:14,代碼來源:PropertyGetIntValuesTests.cs

示例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);
        }
開發者ID:darrencauthon,項目名稱:SisoDb-Provider,代碼行數:14,代碼來源:PropertyGetGuidValuesTests.cs


注:本文中的System.Property.GetIdValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。