public void CustomETagHandlerRoundTrip() { Dictionary <string, object> properties = new Dictionary <string, object> { { "BooleanProperty", (bool)true }, { "IntProperty", (int)123 }, { "GuidProperty", Guid.Empty } }; IETagHandler handler = new MyETagHandler(); // MyETag EntityTagHeaderValue etagHeaderValue = handler.CreateETag(properties); IDictionary <string, object> values = handler.ParseETag(etagHeaderValue); Assert.Equal(properties, values); }
public void CanQueryEntityWithCustomETagHandler() { IEdmModel model = GetEdmModel(); IETagHandler handler = new MyETagHandler(); // MyETag HttpConfiguration configuration = new[] { typeof(CustomersController) }.GetHttpConfiguration(); configuration.SetETagHandler(handler); configuration.MapODataServiceRoute("odata", "odata", model); HttpServer server = new HttpServer(configuration); HttpClient client = new HttpClient(server); string requestUri = "http://localhost/odata/Customers(1)"; HttpRequestMessage request = new HttpRequestMessage(new HttpMethod("Get"), requestUri); HttpResponseMessage response = client.SendAsync(request).Result; response.EnsureSuccessStatusCode(); JObject result = JObject.Parse(response.Content.ReadAsStringAsync().Result); Console.WriteLine(result); Assert.Equal("W/\"IsOk,true/Salary,99\"", result["@odata.etag"]); }