public async Task AllValues_Added(string startValue, ForwardedTransformActions action, string expected)
        {
            var randomFactory = new TestRandomFactory();

            randomFactory.Instance = new TestRandom()
            {
                Sequence = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }
            };
            var httpContext = new DefaultHttpContext();

            httpContext.Request.Scheme             = "https";
            httpContext.Request.Host               = new HostString("myHost", 80);
            httpContext.Connection.RemoteIpAddress = IPAddress.IPv6Loopback;
            httpContext.Connection.RemotePort      = 10;
            var proxyRequest = new HttpRequestMessage();

            proxyRequest.Headers.Add("Forwarded", startValue.Split("|", StringSplitOptions.RemoveEmptyEntries));
            var transform = new RequestHeaderForwardedTransform(randomFactory,
                                                                forFormat: NodeFormat.IpAndPort,
                                                                byFormat: NodeFormat.Random,
                                                                host: true, proto: true, action);
            await transform.ApplyAsync(new RequestTransformContext()
            {
                HttpContext   = httpContext,
                ProxyRequest  = proxyRequest,
                HeadersCopied = true,
            });

            Assert.Equal(expected.Split("|", StringSplitOptions.RemoveEmptyEntries), proxyRequest.Headers.GetValues("Forwarded"));
        }
        public async Task Proto_Added(string startValue, string scheme, ForwardedTransformActions action, string expected)
        {
            var randomFactory = new TestRandomFactory();
            var httpContext   = new DefaultHttpContext();

            httpContext.Request.Scheme = scheme;
            var proxyRequest = new HttpRequestMessage();

            proxyRequest.Headers.Add("Forwarded", startValue.Split("|", StringSplitOptions.RemoveEmptyEntries));
            var transform = new RequestHeaderForwardedTransform(randomFactory, forFormat: NodeFormat.None,
                                                                byFormat: NodeFormat.None, host: false, proto: true, action);
            await transform.ApplyAsync(new RequestTransformContext()
            {
                HttpContext   = httpContext,
                ProxyRequest  = proxyRequest,
                HeadersCopied = true,
            });

            if (string.IsNullOrEmpty(expected))
            {
                Assert.False(proxyRequest.Headers.TryGetValues("Forwarded", out _));
            }
            else
            {
                Assert.Equal(expected.Split("|", StringSplitOptions.RemoveEmptyEntries), proxyRequest.Headers.GetValues("Forwarded"));
            }
        }
        public async Task By_Added(string startValue, string ip, int port, NodeFormat format, ForwardedTransformActions action, string expected)
        {
            var randomFactory = new TestRandomFactory();

            randomFactory.Instance = new TestRandom()
            {
                Sequence = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 }
            };
            var httpContext = new DefaultHttpContext();

            httpContext.Connection.LocalIpAddress = string.IsNullOrEmpty(ip) ? null : IPAddress.Parse(ip);
            httpContext.Connection.LocalPort      = port;
            var proxyRequest = new HttpRequestMessage();

            proxyRequest.Headers.Add("Forwarded", startValue.Split("|", StringSplitOptions.RemoveEmptyEntries));
            var transform = new RequestHeaderForwardedTransform(randomFactory, forFormat: NodeFormat.None,
                                                                byFormat: format, host: false, proto: false, action);
            await transform.ApplyAsync(new RequestTransformContext()
            {
                HttpContext   = httpContext,
                ProxyRequest  = proxyRequest,
                HeadersCopied = true,
            });

            Assert.Equal(expected.Split("|", StringSplitOptions.RemoveEmptyEntries), proxyRequest.Headers.GetValues("Forwarded"));
        }