public IHttpActionResult Put([FromODataUri] string key, [FromBody] ProductWithStringKey product) { key.Should().NotStartWith("'"); key.Should().NotEndWith("'"); return(Updated(Data.Values.First())); }
public async Task It_supports_entities_with_keys_of_type_string_issue_34() { using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(ProductWithStringKeysController)))) { // Arrange var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress); var productToUpdate = new ProductWithStringKey { Id = Guid.NewGuid().ToString(), Name = "Product 1", Price = 2.30 }; // Verify that the OData route in the test controller is valid var response = await httpClient.PutAsJsonAsync($"/odata/ProductWithStringKeys('{productToUpdate.Id}')", productToUpdate); await response.ValidateSuccessAsync(); // Act var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1"); // Assert PathItem pathItem; swaggerDocument.paths.TryGetValue("/odata/ProductWithStringKeys('{Id}')", out pathItem); pathItem.Should().NotBeNull(); pathItem.put.Should().NotBeNull(); await ValidationUtils.ValidateSwaggerJson(); } }
public async Task It_supports_entities_with_keys_of_type_string_issue_34() { using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(ProductWithStringKeysController)))) { // Arrange var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress); var productToUpdate = new ProductWithStringKey { Id = Guid.NewGuid().ToString(), Name = "Product 1", Price = 2.30 }; // Verify that the OData route in the test controller is valid var response = await httpClient.PutAsJsonAsync($"/odata/ProductWithStringKeys('{productToUpdate.Id}')", productToUpdate); await response.ValidateSuccessAsync(); // Act var swaggerDocument = await httpClient.GetJsonAsync<SwaggerDocument>("swagger/docs/v1"); // Assert PathItem pathItem; swaggerDocument.paths.TryGetValue("/odata/ProductWithStringKeys('{Id}')", out pathItem); pathItem.Should().NotBeNull(); pathItem.put.Should().NotBeNull(); await ValidationUtils.ValidateSwaggerJson(); } }