public async Task CreatedResult_ReturnsStatusCode_SetsLocationHeader() { // Arrange var location = "/test/"; var httpContext = GetHttpContext(); var actionContext = GetActionContext(httpContext); var result = new CreatedResult(location, "testInput"); // Act await result.ExecuteResultAsync(actionContext); // Assert Assert.Equal(StatusCodes.Status201Created, httpContext.Response.StatusCode); Assert.Equal(location, httpContext.Response.Headers["Location"]); }
public async Task CreatedResult_ReturnsStatusCode_SetsLocationHeader() { // Arrange var location = "/test/"; var httpContext = GetHttpContext(); var actionContext = GetActionContext(httpContext); var result = new CreatedResult(location, "testInput"); // Act await result.ExecuteResultAsync(actionContext); // Assert Assert.Equal(StatusCodes.Status201Created, httpContext.Response.StatusCode); Assert.Equal(location, httpContext.Response.Headers["Location"]); }
public async Task CreatedResult_OverwritesLocationHeader() { // Arrange var location = "/test/"; var httpContext = GetHttpContext(); var actionContext = GetActionContext(httpContext); httpContext.Response.Headers.Set("Location", "/different/location/"); var result = new CreatedResult(location, "testInput"); // Act await result.ExecuteResultAsync(actionContext); // Assert Assert.Equal(201, httpContext.Response.StatusCode); Assert.Equal(location, httpContext.Response.Headers["Location"]); }