Пример #1
0
        public void GetEntityKeyValue_MultipleKeys_DerivedType_ForDateAndTimeOfDay()
        {
            // Arrange
            var           entityInstance = new { Key1 = new Date(2015, 2, 26), Key2 = new TimeOfDay(1, 2, 3, 4) };
            EdmEntityType baseEntityType = new EdmEntityType("NS", "Name");

            baseEntityType.AddKeys(baseEntityType.AddStructuralProperty("Key1", EdmPrimitiveTypeKind.Date));
            baseEntityType.AddKeys(baseEntityType.AddStructuralProperty("Key2", EdmPrimitiveTypeKind.TimeOfDay));
            EdmEntityType derivedEntityType = new EdmEntityType("NS", "Derived", baseEntityType);

            ResourceContext entityContext = new ResourceContext(_writeContext,
                                                                derivedEntityType.AsReference(), entityInstance);

            // Act
            var keyValue = ConventionsHelpers.GetEntityKeyValue(entityContext);

            // Assert
            Assert.Equal("Key1=2015-02-26,Key2=01:02:03.0040000", keyValue);
        }
Пример #2
0
        public void GetEntityKeyValue_MultipleKeys_DerivedType()
        {
            // Arrange
            var           entityInstance = new { Key1 = "key1", Key2 = 2, Key3 = true };
            EdmEntityType baseEntityType = new EdmEntityType("NS", "Name");

            baseEntityType.AddKeys(baseEntityType.AddStructuralProperty("Key1", EdmPrimitiveTypeKind.String));
            baseEntityType.AddKeys(baseEntityType.AddStructuralProperty("Key2", EdmPrimitiveTypeKind.Int32));
            baseEntityType.AddKeys(baseEntityType.AddStructuralProperty("Key3", EdmPrimitiveTypeKind.Boolean));
            EdmEntityType derivedEntityType = new EdmEntityType("NS", "Derived", baseEntityType);

            ResourceContext entityContext = new ResourceContext(_writeContext, derivedEntityType.AsReference(), entityInstance);

            // Act
            var keyValue = ConventionsHelpers.GetEntityKeyValue(entityContext);

            // Assert
            Assert.Equal("Key1='key1',Key2=2,Key3=true", keyValue);
        }
Пример #3
0
 public void GetUriRepresentationForValue_Works(object value, string result)
 {
     Assert.Equal(
         result,
         ConventionsHelpers.GetUriRepresentationForValue(value));
 }