public async Task ExecuteResultAsync_SetsStatusCodeAndLocationHeader() { // Arrange var expectedUrl = "testAction"; var httpContext = GetHttpContext(); // Act var result = new AcceptedResult(expectedUrl, value: "some-value"); await result.ExecuteAsync(httpContext); // Assert Assert.Equal(StatusCodes.Status202Accepted, httpContext.Response.StatusCode); Assert.Equal(expectedUrl, httpContext.Response.Headers["Location"]); }
public async Task ExecuteResultAsync_FormatsData() { // Arrange var httpContext = GetHttpContext(); var stream = new MemoryStream(); httpContext.Response.Body = stream; // Act var result = new AcceptedResult("my-location", value: "Hello world"); await result.ExecuteAsync(httpContext); // Assert var response = Encoding.UTF8.GetString(stream.ToArray()); Assert.Equal("\"Hello world\"", response); }