public void TestCreate_FormattersForParameter_SupportedMediaTypes()
        {
            // Arrange
            IEdmModel model      = CreateModelWithEntity <SampleType>();
            var       request    = RequestFactory.CreateFromModel(model, "http://any", "odata", new ODataPath());
            var       formatters = CreateInputFormatters(model);

            Assert.NotNull(formatters); // Guard assertion
            var parameterFormatters = formatters.Where(f => CanReadType(f, typeof(ODataActionParameters), request));

            // Act
            var supportedMediaTypes = parameterFormatters.SelectMany(f => f.SupportedMediaTypes).Distinct();

            // Assert
            var expectedMediaTypes = GetMediaTypes(new string[]
            {
                "application/json;odata.metadata=minimal;odata.streaming=true",
                "application/json;odata.metadata=minimal;odata.streaming=false",
                "application/json;odata.metadata=minimal",
                "application/json;odata.metadata=full;odata.streaming=true",
                "application/json;odata.metadata=full;odata.streaming=false",
                "application/json;odata.metadata=full",
                "application/json;odata.metadata=none;odata.streaming=true",
                "application/json;odata.metadata=none;odata.streaming=false",
                "application/json;odata.metadata=none",
                "application/json;odata.streaming=true",
                "application/json;odata.streaming=false",
                "application/json",
            });

            Assert.True(expectedMediaTypes.SequenceEqual(supportedMediaTypes));
        }
        private static MediaTypeHeaderValue GetContentTypeFromQueryString(IEdmModel model, Type type, string dollarFormat)
        {
            var formatters = CreateOutputFormatters(model);
            var path       = new ODataPath();
            var request    = string.IsNullOrEmpty(dollarFormat)
                ? RequestFactory.CreateFromModel(model, "http://any", "OData", path)
                : RequestFactory.CreateFromModel(model, "http://any/?$format=" + dollarFormat, "OData", path);

            var context = new OutputFormatterWriteContext(
                request.HttpContext,
                new TestHttpResponseStreamWriterFactory().CreateWriter,
                type,
                new MemoryStream());

            foreach (var formatter in formatters)
            {
                context.ContentType = new StringSegment();
                context.ContentTypeIsServerDefined = false;

                if (formatter.CanWriteResult(context))
                {
                    MediaTypeHeaderValue mediaType = MediaTypeHeaderValue.Parse(context.ContentType.ToString());

                    // We don't care what the charset is for these tests.
                    if (mediaType.Parameters.Where(p => p.Name == "charset").Any())
                    {
                        mediaType.Parameters.Remove(mediaType.Parameters.Single(p => p.Name == "charset"));
                    }

                    return(mediaType);
                }
            }

            return(null);
        }
        public void Property_EntityIdHeader_IsEvaluatedLazilyAndOnlyOnce()
        {
            // Arrange
            Uri idLink = new Uri("http://id-link");
            Mock <NavigationSourceLinkBuilderAnnotation> linkBuilder = new Mock <NavigationSourceLinkBuilderAnnotation>();

            linkBuilder.CallBase = true;
            linkBuilder.Setup(b => b.BuildIdLink(It.IsAny <ResourceContext>(), ODataMetadataLevel.FullMetadata))
            .Returns(idLink);

            CustomersModelWithInheritance model = new CustomersModelWithInheritance();

            model.Model.SetAnnotationValue(model.Customer, new ClrTypeAnnotation(typeof(TestEntity)));
            model.Model.SetNavigationSourceLinkBuilder(model.Customers, linkBuilder.Object);
            ODataPath      path               = new ODataPath(new EntitySetSegment(model.Customers));
            var            request            = RequestFactory.CreateFromModel(model.Model, path: path);
            TestController controller         = CreateController(request);
            var            createdODataResult = GetCreatedODataResult <TestEntity>(_entity, request, controller);

            // Act
            Uri entityIdHeader = createdODataResult.GenerateEntityId(request);

            // Assert
            Assert.Same(idLink, entityIdHeader);
            linkBuilder.Verify(
                b => b.BuildIdLink(It.IsAny <ResourceContext>(), ODataMetadataLevel.FullMetadata),
                Times.Once());
        }
        public void GenerateLocationHeader_UsesEntitySetLinkBuilder_ToGenerateLocationHeader()
        {
            // Arrange
            Uri editLink = new Uri("http://id-link");
            Mock <NavigationSourceLinkBuilderAnnotation> linkBuilder = new Mock <NavigationSourceLinkBuilderAnnotation>();

            linkBuilder.CallBase = true;
            linkBuilder.Setup(
                b => b.BuildEditLink(It.IsAny <ResourceContext>(), ODataMetadataLevel.FullMetadata, null))
            .Returns(editLink);

            CustomersModelWithInheritance model = new CustomersModelWithInheritance();

            model.Model.SetAnnotationValue(model.Customer, new ClrTypeAnnotation(typeof(TestEntity)));
            model.Model.SetNavigationSourceLinkBuilder(model.Customers, linkBuilder.Object);
            ODataPath path               = new ODataPath(new EntitySetSegment(model.Customers));
            var       request            = RequestFactory.CreateFromModel(model.Model, path: path);
            var       createdODataResult = GetCreatedODataResult <TestEntity>(_entity, request);

            // Act
            var locationHeader = createdODataResult.GenerateLocationHeader(request);

            // Assert
            Assert.Same(editLink, locationHeader);
        }
        public void GenerateNavigationLink_WorksToGenerateExpectedNavigationLink_ForNonContainedNavigation()
        {
            // Arrange
            IEdmEntityType         myOrder            = (IEdmEntityType)_model.Model.FindDeclaredType("NS.MyOrder");
            IEdmNavigationProperty orderLinesProperty = myOrder.NavigationProperties().Single(x => x.Name.Equals("NonContainedOrderLines"));

            IEdmEntitySet entitySet = _model.Model.FindDeclaredEntitySet(("MyOrders"));
            IDictionary <string, object> parameters = new Dictionary <string, object>
            {
                { "ID", 42 }
            };

            IDictionary <string, object> parameters2 = new Dictionary <string, object>
            {
                { "ID", 21 }
            };

            ODataPath path = new ODataPath(
                new EntitySetSegment(entitySet),
                new KeySegment(parameters.ToArray(), myOrder, entitySet),
                new NavigationPropertySegment(orderLinesProperty, _model.NonContainedOrderLines),
                new KeySegment(parameters2.ToArray(), _model.OrderLine, _model.NonContainedOrderLines));

            var request           = RequestFactory.CreateFromModel(_model.Model);
            var serializerContext = ODataSerializerContextFactory.Create(_model.Model, _model.OrderLines, path, request);
            var entityContext     = new ResourceContext(serializerContext, _model.OrderLine.AsReference(), new { ID = 21 });

            // Act
            Uri uri = entityContext.GenerateSelfLink(false);

            // Assert
            Assert.Equal("http://localhost/OrderLines(21)", uri.AbsoluteUri);
        }
        public void SelfLinksGenerationConvention_Uses_GetByIdWithoutCast_IfDerivedTypeDoesnotHaveNavigationProperty()
        {
            ODataConventionModelBuilder builder = ODataConventionModelBuilderFactory.Create();
            var motorcycles = builder.EntitySet <Motorcycle>("motorcycles");

            IEdmModel      model = builder.GetEdmModel();
            IEdmEntitySet  vehiclesEdmEntitySet = model.EntityContainer.EntitySets().Single();
            IEdmEntityType sportbikeType        = model.AssertHasEntityType(typeof(SportBike));

            var request = RequestFactory.CreateFromModel(model);
            NavigationSourceLinkBuilderAnnotation linkBuilder = model.GetNavigationSourceLinkBuilder(vehiclesEdmEntitySet);
            var serializerContext = ODataSerializerContextFactory.Create(model, vehiclesEdmEntitySet, request);
            var entityContext     = new ResourceContext(serializerContext, sportbikeType.AsReference(), new SportBike {
                Model = 2009, Name = "Ninja"
            });

            EntitySelfLinks selfLinks = linkBuilder.BuildEntitySelfLinks(entityContext, ODataMetadataLevel.FullMetadata);

            // This test sometimes writes one of these two:
            //Assert.Equal("http://localhost/motorcycles(Model=2009,Name='Ninja')", );
            //Assert.Equal("http://localhost/motorcycles(Name='Ninja',Model=2009)", );
            var link = selfLinks.IdLink.ToString();

            Assert.Contains("http://localhost/motorcycles", link);
            Assert.Contains("Model=2009", link);
            Assert.Contains("Name='Ninja'", link);
        }
        public void GenerateLocationHeader_ThrowsODataPathMissing_IfRequestDoesNotHaveODataPath()
        {
            var request            = RequestFactory.CreateFromModel(EdmCoreModel.Instance);
            var createdODataResult = GetCreatedODataResult <TestEntity>(_entity, request);

            // Act & Assert
            ExceptionAssert.Throws <InvalidOperationException>(() => createdODataResult.GenerateLocationHeader(request),
                                                               "The operation cannot be completed because no ODataPath is available for the request.");
        }
        public void GenerateLocationHeader_ThrowsEntitySetMissingDuringSerialization_IfODataPathEntitySetIsNull()
        {
            // Arrange
            ODataPath path               = new ODataPath();
            var       request            = RequestFactory.CreateFromModel(EdmCoreModel.Instance, path: path);
            var       createdODataResult = GetCreatedODataResult <TestEntity>(_entity, request);

            // Act & Assert
            ExceptionAssert.Throws <InvalidOperationException>(() => createdODataResult.GenerateLocationHeader(request),
                                                               "The related entity set or singleton cannot be found from the OData path. The related entity set or singleton is required to serialize the payload.");
        }
        public void GenerateActionLink_GeneratesLinkWithoutCast_IfEntitySetTypeMatchesActionEntityType()
        {
            // Arrange
            var request           = RequestFactory.CreateFromModel(_model.Model);
            var serializerContext = ODataSerializerContextFactory.Create(_model.Model, _model.Customers, request);
            var entityContext     = new ResourceContext(serializerContext, _model.Customer.AsReference(), new { ID = 42 });

            // Act
            Uri link = entityContext.GenerateActionLink(_model.UpgradeCustomer);

            Assert.Equal("http://localhost/Customers(42)/NS.upgrade", link.AbsoluteUri);
        }
        public void GenerateLocationHeader_ThrowsEntityTypeNotInModel_IfContentTypeIsNotThereInModel()
        {
            // Arrange
            CustomersModelWithInheritance model = new CustomersModelWithInheritance();
            ODataPath path               = new ODataPath(new EntitySetSegment(model.Customers));
            var       request            = RequestFactory.CreateFromModel(model.Model, path: path);
            var       createdODataResult = GetCreatedODataResult <TestEntity>(_entity, request);

            // Act & Assert
            ExceptionAssert.Throws <InvalidOperationException>(() => createdODataResult.GenerateLocationHeader(request),
                                                               "Cannot find the resource type 'Microsoft.AspNet.OData.Test.Results.CreatedODataResultTest+TestEntity' in the model.");
        }
        public void GenerateSelfLink_WorksToGenerateExpectedSelfLink_ForSingleton(bool includeCast, string expectedIdLink)
        {
            // Arrange
            var request           = RequestFactory.CreateFromModel(_model.Model);
            var serializerContext = ODataSerializerContextFactory.Create(_model.Model, _model.Mary, request);
            var entityContext     = new ResourceContext(serializerContext, _model.SpecialCustomer.AsReference(), new { ID = 42 });

            // Act
            var idLink = entityContext.GenerateSelfLink(includeCast);

            // Assert
            Assert.Equal(expectedIdLink, idLink.ToString());
        }
        public void GenerateActionLink_ReturnsNull_ForContainment()
        {
            // Arrange
            var request           = RequestFactory.CreateFromModel(_model.Model);
            var serializerContext = ODataSerializerContextFactory.Create(_model.Model, _model.OrderLines, request);
            var entityContext     = new ResourceContext(serializerContext, _model.OrderLine.AsReference(), new { ID = 42 });

            // Act
            Uri link = entityContext.GenerateActionLink(_model.Tag);

            // Assert
            Assert.Null(link);
        }
        public void GenerateFunctionLink_GeneratesLinkWithCast_IfEntitySetTypeDoesnotMatchActionEntityType_ForSingleton()
        {
            // Arrange
            var request           = RequestFactory.CreateFromModel(_model.Model);
            var serializerContext = ODataSerializerContextFactory.Create(_model.Model, _model.Mary, request);
            var entityContext     = new ResourceContext(serializerContext, _model.SpecialCustomer.AsReference(), new { ID = 42 });

            // Act
            Uri link = entityContext.GenerateFunctionLink(_model.IsSpecialCustomerUpgraded);

            // Assert
            Assert.Equal("http://localhost/Mary/NS.SpecialCustomer/NS.IsSpecialUpgraded()", link.AbsoluteUri);
        }
        public void GenerateLocationHeader_ThrowsTypeMustBeEntity_IfMappingTypeIsNotEntity()
        {
            CustomersModelWithInheritance model = new CustomersModelWithInheritance();
            ODataPath path    = new ODataPath(new EntitySetSegment(model.Customers));
            var       request = RequestFactory.CreateFromModel(model.Model, path: path);

            model.Model.SetAnnotationValue(model.Address, new ClrTypeAnnotation(typeof(TestEntity)));
            var createdODataResult = GetCreatedODataResult <TestEntity>(_entity, request);

            // Act & Assert
            ExceptionAssert.Throws <InvalidOperationException>(() => createdODataResult.GenerateLocationHeader(request),
                                                               "NS.Address is not an entity type. Only entity types are supported.");
        }
        public void GenerateNavigationLink_WorksToGenerateExpectedNavigationLink_ForSingleton(bool includeCast, string expectedNavigationLink)
        {
            // Arrange
            var request           = RequestFactory.CreateFromModel(_model.Model);
            var serializerContext = ODataSerializerContextFactory.Create(_model.Model, _model.Mary, request);
            var entityContext     = new ResourceContext(serializerContext, _model.SpecialCustomer.AsReference(), new { ID = 42 });
            IEdmNavigationProperty ordersProperty = _model.Customer.NavigationProperties().Single();

            // Act
            Uri uri = entityContext.GenerateNavigationPropertyLink(ordersProperty, includeCast);

            // Assert
            Assert.Equal(expectedNavigationLink, uri.AbsoluteUri);
        }
Exemple #16
0
        public void GetODataDeserializer_ReturnsSameDeserializer_ForSameType()
        {
            // Arrange
            var request = RequestFactory.CreateFromModel(_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 GenerateFunctionLink_GeneratesLinkWithDownCast_IfElementTypeDerivesFromBindingParameterType_ForSingleton()
        {
            // Arrange
            IEdmSingleton me                = new EdmSingleton(_model.Container, "Me", _model.SpecialCustomer);
            var           request           = RequestFactory.CreateFromModel(_model.Model);
            var           serializerContext = ODataSerializerContextFactory.Create(_model.Model, me, request);
            var           entityContext     = new ResourceContext(serializerContext, _model.SpecialCustomer.AsReference(), new { ID = 42 });

            // Act
            Uri link = entityContext.GenerateFunctionLink(_model.IsCustomerUpgraded);

            // Assert
            Assert.Equal("http://localhost/Me/NS.Customer/NS.IsUpgradedWithParam(city=@city)", link.AbsoluteUri);
        }
Exemple #18
0
        public void GetODataSerializer_Enum()
        {
            // Arrange
            var request = RequestFactory.CreateFromModel(GetEnumModel());

            // Act
            var serializer = _serializerProvider.GetODataPayloadSerializer(typeof(TestEnum), request);

            // Assert
            Assert.NotNull(serializer);
            var enumSerializer = Assert.IsType <ODataEnumSerializer>(serializer);

            Assert.Equal(ODataPayloadKind.Property, enumSerializer.ODataPayloadKind);
        }
        public void GenerateActionLink_GeneratesLinkWithDownCast_IfElementTypeDerivesFromBindingParameterType()
        {
            // Arrange
            IEdmEntitySet specialCustomers  = new EdmEntitySet(_model.Container, "SpecialCustomers", _model.SpecialCustomer);
            var           request           = RequestFactory.CreateFromModel(_model.Model);
            var           serializerContext = ODataSerializerContextFactory.Create(_model.Model, specialCustomers, request);
            var           entityContext     = new ResourceContext(serializerContext, _model.SpecialCustomer.AsReference(), new { ID = 42 });

            // Act
            Uri link = entityContext.GenerateActionLink(_model.UpgradeCustomer);

            // Assert
            Assert.Equal("http://localhost/SpecialCustomers(42)/NS.Customer/NS.upgrade", link.AbsoluteUri);
        }
        public void GenerateFunctionLinkForFeed_GeneratesLinkWithCast_IfEntitySetTypeDoesnotMatchActionEntityType()
        {
            // Arrange
            var          request  = RequestFactory.CreateFromModel(_model.Model);
            IEdmFunction function = _model.Model.SchemaElements.OfType <IEdmFunction>().First(a => a.Name == "IsSpecialAllUpgraded");

            Assert.NotNull(function); // Guard
            var context = ResourceSetContextFactory.Create(_model.Customers, request);

            // Act
            Uri link = context.GenerateFunctionLink(function);

            // Assert
            Assert.Equal("http://localhost/Customers/NS.SpecialCustomer/NS.IsSpecialAllUpgraded(param=@param)", link.AbsoluteUri);
        }
Exemple #21
0
        public void GetODataSerializer_Resource_ForComplex()
        {
            // Arrange
            var request = RequestFactory.CreateFromModel(_edmModel);

            // Act
            var serializer = _serializerProvider.GetODataPayloadSerializer(typeof(ODataResourceDeserializerTests.Address), request);

            // Assert
            Assert.NotNull(serializer);
            var complexSerializer = Assert.IsType <ODataResourceSerializer>(serializer);

            Assert.Equal(complexSerializer.SerializerProvider, _serializerProvider);
            Assert.Equal(ODataPayloadKind.Resource, complexSerializer.ODataPayloadKind);
        }
Exemple #22
0
        public void GetODataSerializer_ResourceSet_ForEntityCollection(Type collectionType)
        {
            // Arrange
            var request = RequestFactory.CreateFromModel(_edmModel);

            // Act
            var serializer = _serializerProvider.GetODataPayloadSerializer(collectionType, request);

            // Assert
            Assert.NotNull(serializer);
            var resourceSetSerializer = Assert.IsType <ODataResourceSetSerializer>(serializer);

            Assert.Equal(ODataPayloadKind.ResourceSet, resourceSetSerializer.ODataPayloadKind);
            Assert.Same(resourceSetSerializer.SerializerProvider, _serializerProvider);
        }
        public void GenerateActionLinkForFeed_GeneratesLinkWithoutCast_IfEntitySetTypeMatchesActionEntityType()
        {
            // Arrange
            var        request = RequestFactory.CreateFromModel(_model.Model);
            IEdmAction action  = _model.Model.SchemaElements.OfType <IEdmAction>().First(a => a.Name == "UpgradeAll");

            Assert.NotNull(action); // Guard

            var context = ResourceSetContextFactory.Create(_model.Customers, request);

            // Act
            Uri link = context.GenerateActionLink(action);

            Assert.Equal("http://localhost/Customers/NS.UpgradeAll", link.AbsoluteUri);
        }
        public void Ctor_FollowingConventions_GeneratesSelfLinkWithCast_IfDerivedTypeHasNavigationProperty()
        {
            // Arrange
            CustomersModelWithInheritance model = new CustomersModelWithInheritance();
            var request = RequestFactory.CreateFromModel(model.Model);
            ODataSerializerContext serializerContext = ODataSerializerContextFactory.Create(model.Model, model.Customers, request);
            ResourceContext        instanceContext   = new ResourceContext(serializerContext, model.SpecialCustomer.AsReference(), new { ID = 42 });

            // Act
            NavigationSourceLinkBuilderAnnotation linkBuilder = new NavigationSourceLinkBuilderAnnotation(model.Customers, model.Model);
            var result = linkBuilder.BuildIdLink(instanceContext, ODataMetadataLevel.FullMetadata);

            // Assert
            Assert.Equal("http://localhost/Customers(42)/NS.SpecialCustomer", result.ToString());
        }
Exemple #25
0
        public void GetODataDeserializer_ResourceSet_ForComplexCollection(Type collectionType)
        {
            // Arrange
            var request = RequestFactory.CreateFromModel(_edmModel);

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

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

            Assert.Equal(ODataPayloadKind.ResourceSet, deserializer.ODataPayloadKind);
            Assert.Equal(resourceSetDeserializer.DeserializerProvider, _deserializerProvider);
        }
Exemple #26
0
        public void GetODataDeserializer_Resource_ForEntity()
        {
            // Arrange
            var request = RequestFactory.CreateFromModel(_edmModel);

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

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

            Assert.Equal(ODataPayloadKind.Resource, deserializer.ODataPayloadKind);
            Assert.Equal(entityDeserializer.DeserializerProvider, _deserializerProvider);
        }
        public void GenerateLocationHeader_ThrowsEditLinkNullForLocationHeader_IfEntitySetLinkBuilderReturnsNull()
        {
            // Arrange
            Mock <NavigationSourceLinkBuilderAnnotation> linkBuilder = new Mock <NavigationSourceLinkBuilderAnnotation>();
            CustomersModelWithInheritance model = new CustomersModelWithInheritance();

            model.Model.SetAnnotationValue(model.Customer, new ClrTypeAnnotation(typeof(TestEntity)));
            model.Model.SetNavigationSourceLinkBuilder(model.Customers, linkBuilder.Object);
            ODataPath path               = new ODataPath(new EntitySetSegment(model.Customers));
            var       request            = RequestFactory.CreateFromModel(model.Model, path: path);
            var       createdODataResult = GetCreatedODataResult <TestEntity>(_entity, request);

            // Act
            ExceptionAssert.Throws <InvalidOperationException>(() => createdODataResult.GenerateLocationHeader(request),
                                                               "The edit link builder for the entity set 'Customers' returned null. An edit link is required for the location header.");
        }
Exemple #28
0
        public void GenerateODataLink_ThrowsIdLinkNullForEntityIdHeader_IfEntitySetLinkBuilderReturnsNull()
        {
            // Arrange
            var linkBuilder = new Mock <NavigationSourceLinkBuilderAnnotation>();
            var model       = new CustomersModelWithInheritance();

            model.Model.SetAnnotationValue(model.Customer, new ClrTypeAnnotation(typeof(TestEntity)));
            model.Model.SetNavigationSourceLinkBuilder(model.Customers, linkBuilder.Object);
            var path    = new ODataPath(new EntitySetSegment(model.Customers));
            var request = RequestFactory.CreateFromModel(model.Model, path: path);

            // Act & Assert
            ExceptionAssert.Throws <InvalidOperationException>(
                () => ResultHelpers.GenerateODataLink(request, _entity, isEntityId: true),
                "The Id link builder for the entity set 'Customers' returned null. An Id link is required for the OData-EntityId header.");
        }
Exemple #29
0
        public void GetODataPayloadSerializer_ReturnsRawValueSerializer_ForValueRequests(Type type, EdmPrimitiveTypeKind edmPrimitiveTypeKind)
        {
            // Arrange
            ODataPath odataPath = new ODataPath(new ValueSegment(EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Int32)));
            var       request   = RequestFactory.CreateFromModel(_edmModel);

            request.ODataContext().Path = odataPath;

            // Act
            var serializer = _serializerProvider.GetODataPayloadSerializer(type, request);

            // Assert
            Assert.NotEqual(EdmPrimitiveTypeKind.None, edmPrimitiveTypeKind);
            Assert.NotNull(serializer);
            Assert.Equal(ODataPayloadKind.Value, serializer.ODataPayloadKind);
        }
        public void GenerateFunctionLinkForFeed_GeneratesLinkWithDownCast_IfElementTypeDerivesFromBindingParameterType()
        {
            // Arrange
            var          request  = RequestFactory.CreateFromModel(_model.Model);
            IEdmFunction function = _model.Model.SchemaElements.OfType <IEdmFunction>().First(a => a.Name == "IsAllUpgraded");

            Assert.NotNull(function); // Guard
            IEdmEntitySet specialCustomers = new EdmEntitySet(_model.Container, "SpecialCustomers", _model.SpecialCustomer);

            var context = ResourceSetContextFactory.Create(specialCustomers, request);

            // Act
            Uri link = context.GenerateFunctionLink(function);

            // Assert
            Assert.Equal("http://localhost/SpecialCustomers/NS.Customer/NS.IsAllUpgraded(param=@param)", link.AbsoluteUri);
        }