public void CreateODataOperations_CreateOperations(bool followConventions)
        {
            // Arrange
            // Arrange
            string expectedTarget = "aa://Target";
            ODataResourceSetSerializer serializer = new ODataResourceSetSerializer(_serializerProvider);
            var builder = new ODataConventionModelBuilder();

            builder.EntitySet <FeedCustomer>("Customers");
            var function = builder.EntityType <FeedCustomer>().Collection.Function("MyFunction").Returns <int>();

            function.HasFeedFunctionLink(a => new Uri(expectedTarget), followConventions);
            IEdmModel model = builder.GetEdmModel();

            IEdmEntitySet customers              = model.EntityContainer.FindEntitySet("Customers");
            IEdmFunction  edmFunction            = model.SchemaElements.OfType <IEdmFunction>().First(f => f.Name == "MyFunction");
            string        expectedMetadataPrefix = "http://Metadata";

            UrlHelper          url                = CreateMetadataLinkFactory(expectedMetadataPrefix);
            HttpRequestMessage request            = new HttpRequestMessage();
            ResourceSetContext resourceSetContext = new ResourceSetContext
            {
                EntitySetBase = customers,
                Request       = request,
                Url           = url
            };

            ODataSerializerContext serializerContext = new ODataSerializerContext
            {
                NavigationSource = customers,
                Request          = request,
                Model            = model,
                MetadataLevel    = ODataMetadataLevel.FullMetadata,
                Url = url
            };

            // Act
            ODataOperation actualOperation = serializer.CreateODataOperation(edmFunction, resourceSetContext, serializerContext);

            // Assert
            Assert.NotNull(actualOperation);
            string         expectedMetadata = expectedMetadataPrefix + "#Default.MyFunction";
            ODataOperation expectedFunction = new ODataFunction
            {
                Metadata = new Uri(expectedMetadata),
                Target   = new Uri(expectedTarget),
                Title    = "MyFunction"
            };

            AssertEqual(expectedFunction, actualOperation);
        }
        public void CreateODataOperation_OmitsOperations_WhenNonFullMetadata(ODataMetadataLevel metadataLevel)
        {
            // Arrange
            ODataResourceSetSerializer serializer = new ODataResourceSetSerializer(_serializerProvider);

            IEdmTypeReference returnType = EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Boolean, isNullable: false);
            IEdmFunction      function   = new EdmFunction("NS", "Function", returnType, isBound: true, entitySetPathExpression: null, isComposable: false);

            ResourceSetContext     resourceSetContext = new ResourceSetContext();
            ODataSerializerContext serializerContext  = new ODataSerializerContext
            {
                MetadataLevel = metadataLevel
            };
            // Act

            ODataOperation operation = serializer.CreateODataOperation(function, resourceSetContext, serializerContext);

            // Assert
            Assert.Null(operation);
        }