public void HasFeedActionLink_ThrowsException_OnNonBindableActions() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); ActionConfiguration action = builder.Action("NoBindableAction"); // Act & Assert Assert.Throws <InvalidOperationException>( () => action.HasFeedActionLink(ctx => new Uri("http://any"), followsConventions: false), "To register an action link factory, actions must be bindable to the collection of entity. " + "Action 'NoBindableAction' does not meet this requirement."); }
public void CanManuallyConfigureFeedActionLinkFactory() { // 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); ActionConfiguration reward = customer.Collection.Action("Reward"); reward.HasFeedActionLink(ctx => expectedUri, followsConventions: false); IEdmModel model = builder.GetEdmModel(); // Act IEdmAction rewardAction = Assert.Single(model.SchemaElements.OfType <IEdmAction>()); // Guard OperationLinkBuilder actionLinkBuilder = model.GetAnnotationValue <OperationLinkBuilder>(rewardAction); ResourceSetContext context = new ResourceSetContext(); //Assert Assert.Equal(expectedUri, reward.GetFeedActionLink()(context)); Assert.NotNull(actionLinkBuilder); Assert.Equal(expectedUri, actionLinkBuilder.BuildLink(context)); }