public void Set_AddsNewQueryStringParameter() { var httpContext = new DefaultHttpContext(); var context = new RequestParametersTransformContext() { Query = new QueryTransformContext(httpContext.Request), HttpContext = httpContext }; var transform = new QueryParameterFromStaticTransform(QueryStringTransformMode.Set, "z", "foo"); transform.Apply(context); Assert.Equal("?z=foo", context.Query.QueryString.Value); }
public async Task Append_AddsQueryStringParameterWithStaticValue() { var httpContext = new DefaultHttpContext(); var context = new RequestTransformContext() { Query = new QueryTransformContext(httpContext.Request), HttpContext = httpContext }; var transform = new QueryParameterFromStaticTransform(QueryStringTransformMode.Append, "z", "foo"); await transform.ApplyAsync(context); Assert.Equal("?z=foo", context.Query.QueryString.Value); }
public void Append_IgnoresExistingQueryStringParameter() { var httpContext = new DefaultHttpContext(); httpContext.Request.QueryString = new QueryString("?z=1"); var context = new RequestParametersTransformContext() { Query = new QueryTransformContext(httpContext.Request), HttpContext = httpContext }; var transform = new QueryParameterFromStaticTransform(QueryStringTransformMode.Append, "z", "foo"); transform.Apply(context); Assert.Equal("?z=1&z=foo", context.Query.QueryString.Value); }
public async Task Set_OverwritesExistingQueryStringParameter() { var httpContext = new DefaultHttpContext(); httpContext.Request.QueryString = new QueryString("?z=1"); var context = new RequestTransformContext() { Query = new QueryTransformContext(httpContext.Request), HttpContext = httpContext }; var transform = new QueryParameterFromStaticTransform(QueryStringTransformMode.Set, "z", "foo"); await transform.ApplyAsync(context); Assert.Equal("?z=foo", context.Query.QueryString.Value); }