public void Constructor_InitializesStatusCodeAndValue(object value) { // Arrange & Act var result = new AcceptedResult("testlocation", value); // Assert Assert.Equal(StatusCodes.Status202Accepted, result.StatusCode); Assert.Same(value, result.Value); }
public async Task ExecuteResultAsync_SetsStatusCodeAndLocationHeader() { // Arrange var location = "/test/"; var formatter = CreateMockFormatter(); var httpContext = GetHttpContext(formatter); var actionContext = GetActionContext(httpContext); // Act var result = new AcceptedResult(location, "testInput"); await result.ExecuteResultAsync(actionContext); // Assert Assert.Equal(StatusCodes.Status202Accepted, httpContext.Response.StatusCode); Assert.Equal(location, httpContext.Response.Headers["Location"]); }
public async Task ExecuteResultAsync_SetsObjectValueOfFormatter(object value) { // Arrange var location = "/test/"; var formatter = CreateMockFormatter(); var httpContext = GetHttpContext(formatter); object actual = null; formatter.Setup(f => f.WriteAsync(It.IsAny <OutputFormatterWriteContext>())) .Callback((OutputFormatterWriteContext context) => actual = context.Object) .Returns(Task.FromResult(0)); var actionContext = GetActionContext(httpContext); // Act var result = new AcceptedResult(location, value); await result.ExecuteResultAsync(actionContext); // Assert Assert.Same(value, actual); }