protected override Task ExecuteAsync(HttpContext httpContext, string contentPath) { httpContext.RequestServices = GetServiceProvider(); var actionContext = new ActionContext(httpContext, new(), new()); var redirectResult = new RedirectResult(contentPath); return(redirectResult.ExecuteResultAsync(actionContext)); }
public async Task Execute_ReturnsAppRelativePath_WhenItStartsWithTilde( string appRoot, string contentPath, string expectedPath) { // Arrange var httpContext = GetHttpContext(appRoot); var actionContext = GetActionContext(httpContext); var result = new RedirectResult(contentPath); // Act await result.ExecuteResultAsync(actionContext); // Assert // Verifying if Redirect was called with the specific Url and parameter flag. Assert.Equal(expectedPath, httpContext.Response.Headers[HeaderNames.Location].ToString()); Assert.Equal(StatusCodes.Status302Found, httpContext.Response.StatusCode); }
public async Task Execute_ReturnsAppRelativePath_WhenItStartsWithTilde( string appRoot, string contentPath, string expectedPath) { // Arrange var httpResponse = new Mock <HttpResponse>(); httpResponse.Setup(o => o.Redirect(expectedPath, false)) .Verifiable(); var httpContext = GetHttpContext(appRoot, contentPath, expectedPath, httpResponse.Object); var actionContext = GetActionContext(httpContext); var result = new RedirectResult(contentPath); // Act await result.ExecuteResultAsync(actionContext); // Assert // Verifying if Redirect was called with the specific Url and parameter flag. httpResponse.Verify(); }