public void GetODataDeserializer_ReturnsSameDeserializer_ForSameType()
        {
            ODataDeserializerProvider deserializerProvider = new DefaultODataDeserializerProvider();
            HttpRequestMessage        request = new HttpRequestMessage();

            ODataDeserializer firstCallDeserializer = deserializerProvider.GetODataDeserializer(_edmModel,
                                                                                                typeof(ODataEntityDeserializerTests.Supplier), request);
            ODataDeserializer secondCallDeserializer = deserializerProvider.GetODataDeserializer(_edmModel,
                                                                                                 typeof(ODataEntityDeserializerTests.Supplier), request);

            Assert.Same(firstCallDeserializer, secondCallDeserializer);
        }
        public void GetODataDeserializer_Primitive(Type type, EdmPrimitiveTypeKind primitiveKind)
        {
            ODataDeserializerProvider deserializerProvider = new DefaultODataDeserializerProvider();
            HttpRequestMessage        request = new HttpRequestMessage();

            ODataDeserializer deserializer = deserializerProvider.GetODataDeserializer(_edmModel, type, request);

            Assert.NotNull(deserializer);
            ODataPrimitiveDeserializer rawValueDeserializer = Assert.IsType <ODataPrimitiveDeserializer>(deserializer);

            Assert.Equal(ODataPayloadKind.Property, rawValueDeserializer.ODataPayloadKind);
        }
        public void GetODataDeserializer_Uri()
        {
            ODataDeserializerProvider deserializerProvider = new DefaultODataDeserializerProvider();
            HttpRequestMessage        request = new HttpRequestMessage();

            ODataDeserializer deserializer = deserializerProvider.GetODataDeserializer(_edmModel, typeof(Uri), request);

            Assert.NotNull(deserializer);
            var referenceLinkDeserializer = Assert.IsType <ODataEntityReferenceLinkDeserializer>(deserializer);

            Assert.Equal(ODataPayloadKind.EntityReferenceLink, referenceLinkDeserializer.ODataPayloadKind);
        }
        public void GetODataDeserializer_Complex()
        {
            ODataDeserializerProvider deserializerProvider = new DefaultODataDeserializerProvider();
            HttpRequestMessage        request = new HttpRequestMessage();

            ODataDeserializer deserializer = deserializerProvider.GetODataDeserializer(_edmModel,
                                                                                       typeof(ODataEntityDeserializerTests.Address), request);

            Assert.NotNull(deserializer);
            ODataComplexTypeDeserializer complexDeserializer = Assert.IsType <ODataComplexTypeDeserializer>(deserializer);

            Assert.Equal(deserializer.ODataPayloadKind, ODataPayloadKind.Property);
            Assert.Equal(complexDeserializer.DeserializerProvider, deserializerProvider);
        }
        public void GetODataDeserializer_Entity()
        {
            ODataDeserializerProvider deserializerProvider = new DefaultODataDeserializerProvider();
            HttpRequestMessage        request = new HttpRequestMessage();

            ODataDeserializer deserializer = deserializerProvider.GetODataDeserializer(_edmModel,
                                                                                       typeof(ODataEntityDeserializerTests.Product), request);

            Assert.NotNull(deserializer);
            ODataEntityDeserializer entityDeserializer = Assert.IsType <ODataEntityDeserializer>(deserializer);

            Assert.Equal(deserializer.ODataPayloadKind, ODataPayloadKind.Entry);
            Assert.Equal(entityDeserializer.DeserializerProvider, deserializerProvider);
        }
        public void GetODataDeserializer_Uri()
        {
            // Arrange
            HttpRequestMessage request = new HttpRequestMessage();

            // Act
            ODataDeserializer deserializer = _deserializerProvider.GetODataDeserializer(typeof(Uri), request);

            // Assert
            Assert.NotNull(deserializer);
            var referenceLinkDeserializer = Assert.IsType <ODataEntityReferenceLinkDeserializer>(deserializer);

            Assert.Equal(ODataPayloadKind.EntityReferenceLink, referenceLinkDeserializer.ODataPayloadKind);
        }
        public void GetODataDeserializer_Primitive(Type type, EdmPrimitiveTypeKind primitiveKind)
        {
            // Arrange
            HttpRequestMessage request = new HttpRequestMessage();

            request.EnableHttpDependencyInjectionSupport();

            // Act
            ODataDeserializer deserializer = _deserializerProvider.GetODataDeserializer(type, request);

            // Assert
            Assert.NotNull(deserializer);
            ODataPrimitiveDeserializer rawValueDeserializer = Assert.IsType <ODataPrimitiveDeserializer>(deserializer);

            Assert.Equal(ODataPayloadKind.Property, rawValueDeserializer.ODataPayloadKind);
        }
        public void GetODataDeserializer_ReturnsSameDeserializer_ForSameType()
        {
            // Arrange
            HttpRequestMessage request = new HttpRequestMessage();

            request.EnableHttpDependencyInjectionSupport(_edmModel);

            // Act
            ODataDeserializer firstCallDeserializer = _deserializerProvider.GetODataDeserializer(
                typeof(ODataResourceDeserializerTests.Supplier), request);
            ODataDeserializer secondCallDeserializer = _deserializerProvider.GetODataDeserializer(
                typeof(ODataResourceDeserializerTests.Supplier), request);

            // Assert
            Assert.Same(firstCallDeserializer, secondCallDeserializer);
        }
        public void GetODataDeserializer_ResourceSet_ForComplexCollection(Type collectionType)
        {
            // Arrange
            HttpRequestMessage request = new HttpRequestMessage();

            request.EnableHttpDependencyInjectionSupport(_edmModel);

            // Act
            ODataDeserializer deserializer = _deserializerProvider.GetODataDeserializer(collectionType, request);

            // Assert
            Assert.NotNull(deserializer);
            ODataResourceSetDeserializer resourceSetDeserializer = Assert.IsType <ODataResourceSetDeserializer>(deserializer);

            Assert.Equal(deserializer.ODataPayloadKind, ODataPayloadKind.ResourceSet);
            Assert.Equal(resourceSetDeserializer.DeserializerProvider, _deserializerProvider);
        }
        public void GetODataDeserializer_Resource_ForComplex()
        {
            // Arrange
            HttpRequestMessage request = new HttpRequestMessage();

            request.EnableHttpDependencyInjectionSupport(_edmModel);

            // Act
            ODataDeserializer deserializer = _deserializerProvider.GetODataDeserializer(
                typeof(ODataResourceDeserializerTests.Address), request);

            // Assert
            Assert.NotNull(deserializer);
            ODataResourceDeserializer complexDeserializer = Assert.IsType <ODataResourceDeserializer>(deserializer);

            Assert.Equal(deserializer.ODataPayloadKind, ODataPayloadKind.Resource);
            Assert.Equal(complexDeserializer.DeserializerProvider, _deserializerProvider);
        }