public void ApplyQuery_SingleEntity_ThrowsArgumentNull_QueryOptions() { QueryableAttribute attribute = new QueryableAttribute(); Assert.ThrowsArgumentNull( () => attribute.ApplyQuery(entity: 42, queryOptions: null), "queryOptions"); }
public void ApplyQuery_Throws_WithNullQueryOptions() { // Arrange QueryableAttribute attribute = new QueryableAttribute(); // Act & Assert Assert.ThrowsArgumentNull(() => attribute.ApplyQuery(CustomerList.AsQueryable(), null), "queryOptions"); }
public void ApplyQuery_SingleEntity_ThrowsArgumentNull_Entity() { QueryableAttribute attribute = new QueryableAttribute(); ODataQueryOptions options = new ODataQueryOptions(new ODataQueryContext(EdmCoreModel.Instance, typeof(int)), new HttpRequestMessage()); Assert.ThrowsArgumentNull( () => attribute.ApplyQuery(entity: null, queryOptions: options), "entity"); }
public void ApplyQuery_Throws_With_Null_Queryable() { // Arrange QueryableAttribute attribute = new QueryableAttribute(); var model = new ODataModelBuilder().Add_Customer_EntityType().Add_Customers_EntitySet().GetEdmModel(); var options = new ODataQueryOptions(new ODataQueryContext(model, typeof(System.Web.Http.OData.Builder.TestModels.Customer)), new HttpRequestMessage()); // Act & Assert Assert.ThrowsArgumentNull(() => attribute.ApplyQuery(null, options), "queryable"); }
public void ApplyQuery_Accepts_All_Supported_QueryNames(string query) { // Arrange QueryableAttribute attribute = new QueryableAttribute(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/?" + query); var model = new ODataModelBuilder().Add_Customer_EntityType().Add_Customers_EntitySet().GetEdmModel(); var options = new ODataQueryOptions(new ODataQueryContext(model, typeof(System.Web.Http.OData.Builder.TestModels.Customer)), request); // Act & Assert Assert.DoesNotThrow(() => attribute.ApplyQuery(new List <System.Web.Http.OData.Builder.TestModels.Customer>().AsQueryable(), options)); }
public void ApplyQuery_CallsApplyOnODataQueryOptions() { object entity = new object(); QueryableAttribute attribute = new QueryableAttribute(); ODataQueryContext context = new ODataQueryContext(EdmCoreModel.Instance, typeof(int)); HttpRequestMessage request = new HttpRequestMessage(); Mock <ODataQueryOptions> queryOptions = new Mock <ODataQueryOptions>(context, request); attribute.ApplyQuery(entity, queryOptions.Object); queryOptions.Verify(q => q.ApplyTo(entity, It.IsAny <ODataQuerySettings>()), Times.Once()); }
public void ApplyQuery_Accepts_All_Supported_QueryNames(string query) { // Arrange QueryableAttribute attribute = new QueryableAttribute(); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/?" + query); var model = new ODataModelBuilder().Add_Customer_EntityType().Add_Customers_EntitySet().GetEdmModel(); var options = new ODataQueryOptions(new ODataQueryContext(model, typeof(System.Web.Http.OData.Builder.TestModels.Customer)), request); // Act & Assert Assert.DoesNotThrow(() => attribute.ApplyQuery(new List<System.Web.Http.OData.Builder.TestModels.Customer>().AsQueryable(), options)); }