public async Task CreatedNegotiatedContentResult_SetsLocation_String(string uri) { // Arrange var httpContext = new DefaultHttpContext(); httpContext.RequestServices = CreateServices(); var stream = new MemoryStream(); httpContext.Response.Body = stream; var context = new ActionContext(new RouteContext(httpContext), new ActionDescriptor()); var result = new CreatedNegotiatedContentResult <Product>( new Uri(uri, UriKind.RelativeOrAbsolute), new Product()); // Act await result.ExecuteResultAsync(context); // Assert Assert.Equal(uri, httpContext.Response.Headers["Location"]); }
public async Task CreatedNegotiatedContentResult_SetsLocation_Uri() { // Arrange var httpContext = new DefaultHttpContext(); httpContext.RequestServices = CreateServices(); var stream = new MemoryStream(); httpContext.Response.Body = stream; var uri = new Uri("http://contoso.com"); var context = new ActionContext(new RouteContext(httpContext), new ActionDescriptor()); var result = new CreatedNegotiatedContentResult <Product>(uri, new Product()); // Act await result.ExecuteResultAsync(context); // Assert Assert.Equal("http://contoso.com/", httpContext.Response.Headers["Location"]); }