예제 #1
0
        public async Task WriteResourceEndMetadataPropertiesAsync_WritesNavigationAndStreamMetadataProperties()
        {
            var resource = CreateCategoryResource();

            resource.MetadataBuilder = new TestODataResourceMetadataBuilder(
                resource: resource,
                unprocessedNavigationLinksFactory: () => GetNavigationLinks(resource.Id),
                unprocessedStreamPropertiesFactory: () => GetStreamProperties(resource.Id));

            var jsonLightWriterResourceState = new TestODataJsonLightWriterResourceState(
                resource,
                this.categoryEntityType,
                CreateCategorySerializationInfo(),
                this.categoriesEntitySet,
                false);

            var result = await SetupJsonLightResourceSerializerAndRunTestAsync(
                (jsonLightResourceSerializer) =>
            {
                return(jsonLightResourceSerializer.WriteResourceEndMetadataPropertiesAsync(
                           jsonLightWriterResourceState,
                           new NullDuplicatePropertyNameChecker()));
            });

            Assert.Equal("{\"[email protected]\":\"http://tempuri.org/Categories(1)/associationLink\"," +
                         "\"[email protected]\":\"http://tempuri.org/Categories(1)/navigationLink\"," +
                         "\"[email protected]\":\"http://tempuri.org/Categories(1)/blob/editLink\"," +
                         "\"[email protected]\":\"http://tempuri.org/Categories(1)/blob/readLink\"," +
                         "\"[email protected]\":\"image/png\"," +
                         "\"[email protected]\":\"blob-etag\"",
                         result);
        }
예제 #2
0
        public async Task WriteResourceStartMetadataPropertiesAsync_WritesResourceMetadataProperties(bool isUndeclared, string expected)
        {
            var jsonLightWriterResourceState = new TestODataJsonLightWriterResourceState(
                CreateCategoryResource(),
                this.categoryEntityType,
                CreateCategorySerializationInfo(),
                this.categoriesEntitySet,
                isUndeclared);

            var result = await SetupJsonLightResourceSerializerAndRunTestAsync(
                (jsonLightResourceSerializer) =>
            {
                return(jsonLightResourceSerializer.WriteResourceStartMetadataPropertiesAsync(
                           jsonLightWriterResourceState));
            });

            Assert.Equal(expected, result);
        }
예제 #3
0
        public async Task WriteResourceEndMetadataPropertiesAsync_WritesActionsAndFunctionsMetadataProperties(ODataResource resource, string expected)
        {
            var jsonLightWriterResourceState = new TestODataJsonLightWriterResourceState(
                resource,
                this.categoryEntityType,
                CreateCategorySerializationInfo(),
                this.categoriesEntitySet,
                false);

            var result = await SetupJsonLightResourceSerializerAndRunTestAsync(
                (jsonLightResourceSerializer) =>
            {
                return(jsonLightResourceSerializer.WriteResourceEndMetadataPropertiesAsync(
                           jsonLightWriterResourceState,
                           new NullDuplicatePropertyNameChecker()));
            });

            Assert.Equal(expected, result);
        }
예제 #4
0
        public async Task WriteResourceStartMetadataPropertiesAsync_WritesETagMetadataProperty()
        {
            var resource = CreateCategoryResource();

            resource.ETag = "etag";

            var jsonLightWriterResourceState = new TestODataJsonLightWriterResourceState(
                resource,
                this.categoryEntityType,
                CreateCategorySerializationInfo(),
                this.categoriesEntitySet,
                false);

            var result = await SetupJsonLightResourceSerializerAndRunTestAsync(
                (jsonLightResourceSerializer) =>
            {
                return(jsonLightResourceSerializer.WriteResourceStartMetadataPropertiesAsync(
                           jsonLightWriterResourceState));
            });

            Assert.Equal("{\"@odata.id\":\"http://tempuri.org/Categories(1)\",\"@odata.etag\":\"etag\"", result);
        }