public async Task LeavesOtherQueryParameters() { var httpContext = new DefaultHttpContext(); httpContext.Request.QueryString = new QueryString("?z=1&a=2"); var context = new RequestTransformContext() { Query = new QueryTransformContext(httpContext.Request), }; var transform = new QueryParameterRemoveTransform("z"); await transform.ApplyAsync(context); Assert.Equal("?a=2", context.Query.QueryString.Value); }
public async Task DoesNotFailOnNonExistingQueryParameter() { var httpContext = new DefaultHttpContext(); httpContext.Request.QueryString = new QueryString("?z=1"); var context = new RequestTransformContext() { Query = new QueryTransformContext(httpContext.Request), }; var transform = new QueryParameterRemoveTransform("a"); await transform.ApplyAsync(context); Assert.Equal("?z=1", context.Query.QueryString.Value); }
public async Task RemovesExistingQueryParameter() { var httpContext = new DefaultHttpContext(); httpContext.Request.QueryString = new QueryString("?z=1"); var context = new RequestTransformContext() { Query = new QueryTransformContext(httpContext.Request) }; var transform = new QueryParameterRemoveTransform("z"); await transform.ApplyAsync(context); Assert.False(context.Query.QueryString.HasValue); }