public void HasFeedFunctionLink_ThrowsException_OnNonBindableFunctions() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); FunctionConfiguration function = builder.Function("NoBindableFunction"); // Act & Assert ExceptionAssert.Throws <InvalidOperationException>( () => function.HasFeedFunctionLink(ctx => new Uri("http://any"), followsConventions: false), "To register a function link factory, functions must be bindable to the collection of entity. " + "Function 'NoBindableFunction' does not meet this requirement."); }
public void CanManuallyConfigureFeedFunctionLinkFactory() { // Arrange Uri expectedUri = new Uri("http://localhost/service/Customers/Reward"); ODataModelBuilder builder = new ODataModelBuilder(); EntityTypeConfiguration <Customer> customer = builder.EntitySet <Customer>("Customers").EntityType; customer.HasKey(c => c.CustomerId); customer.Property(c => c.Name); FunctionConfiguration reward = customer.Collection.Function("Reward").Returns <int>(); reward.HasFeedFunctionLink(ctx => expectedUri, followsConventions: false); IEdmModel model = builder.GetEdmModel(); // Act IEdmFunction rewardFuntion = Assert.Single(model.SchemaElements.OfType <IEdmFunction>()); // Guard OperationLinkBuilder functionLinkBuilder = model.GetAnnotationValue <OperationLinkBuilder>(rewardFuntion); ResourceSetContext context = new ResourceSetContext(); //Assert Assert.Equal(expectedUri, reward.GetFeedFunctionLink()(context)); Assert.NotNull(functionLinkBuilder); Assert.Equal(expectedUri, functionLinkBuilder.BuildLink(context)); }