Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }