public void GetEdmModel_ThrowsException_WhenBoundActionOverloaded() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); EntityTypeConfiguration <Customer> customer = builder.EntityType <Customer>(); customer.HasKey(c => c.CustomerId); customer.Property(c => c.Name); customer.Action("ActionOnCustomer"); customer.Action("ActionOnCustomer").Returns <string>(); // Act & Assert InvalidOperationException exception = Assert.Throws <InvalidOperationException>(() => builder.GetEdmModel()); Assert.Equal(exception.Message, "Found more than one action with name 'ActionOnCustomer' " + "bound to the same type 'Microsoft.AspNetCore.OData.Models.Customer'. " + "Each bound action must have a different binding type or name."); }
public void CanCreateEdmModel_WithBindableAction() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); EntityTypeConfiguration <Customer> customer = builder.EntityType <Customer>(); customer.HasKey(c => c.CustomerId); customer.Property(c => c.Name); // Act customer.Action("ActionName"); IEdmModel model = builder.GetEdmModel(); // Assert IEdmAction action = Assert.Single(model.SchemaElements.OfType <IEdmAction>()); Assert.True(action.IsBound); Assert.Equal("ActionName", action.Name); Assert.Null(action.ReturnType); Assert.Single(action.Parameters); Assert.Equal(BindingParameterConfiguration.DefaultBindingParameterName, action.Parameters.Single().Name); Assert.Equal(typeof(Customer).FullName, action.Parameters.Single().Type.FullName()); }