public void It_handles_non_http_requests_without_trying_to_inect_cookies()
        {
            var requestUri = new Uri("ftp://cookiemonster.love/cookies/");
            var expectedCookies = new List<Cookie>{new Cookie("n1","v1","/","cookiemonster.love")};

            var webClient = new WebClientWithCookiesTestExtensionYuk();

            webClient.SetCookies(expectedCookies);
            var webRequest = webClient.GetWebRequest(requestUri);

            Assert.That(webRequest, Is.InstanceOf(typeof(FtpWebRequest)));
        }
        public void It_handles_non_http_requests_without_trying_to_inect_cookies()
        {
            var requestUri      = new Uri("ftp://cookiemonster.love/cookies/");
            var expectedCookies = new List <Cookie> {
                new Cookie("n1", "v1", "/", "cookiemonster.love")
            };

            var webClient = new WebClientWithCookiesTestExtensionYuk();

            webClient.SetCookies(expectedCookies);
            var webRequest = webClient.GetWebRequest(requestUri);

            Assert.That(webRequest, Is.InstanceOf(typeof(FtpWebRequest)));
        }
        public void It_injects_cookies_into_the_web_request()
        {
            var requestUri      = new Uri("http://cookiemonster.love/cookies/");
            var expectedCookies = new List <Cookie>
            {
                new Cookie("n1", "v1", "/", "cookiemonster.love"),
                new Cookie("n2", "v2", "/", "cookiemonster.love"),
                new Cookie("n3", "v3", "/cookies/", "cookiemonster.love"),
            };

            var webClient = new WebClientWithCookiesTestExtensionYuk();

            webClient.SetCookies(expectedCookies);
            var webRequest = webClient.GetWebRequest(requestUri);

            var actualCookies = ((HttpWebRequest)webRequest).CookieContainer.GetCookies(requestUri);

            Assert.That(actualCookies.Count, Is.EqualTo(3));
            Assert.That(actualCookies, Has.Member(expectedCookies[0]));
            Assert.That(actualCookies, Has.Member(expectedCookies[1]));
            Assert.That(actualCookies, Has.Member(expectedCookies[2]));
        }
        public void It_injects_cookies_into_the_web_request()
        {
            var requestUri = new Uri("http://cookiemonster.love/cookies/");
            var expectedCookies = new List<Cookie>
                                      {
                                          new Cookie("n1","v1","/","cookiemonster.love"),
                                          new Cookie("n2","v2","/","cookiemonster.love"),
                                          new Cookie("n3","v3","/cookies/","cookiemonster.love"),
                                      };

            var webClient = new WebClientWithCookiesTestExtensionYuk();

            webClient.SetCookies(expectedCookies);
            var webRequest = webClient.GetWebRequest(requestUri);

            var actualCookies = ((HttpWebRequest)webRequest).CookieContainer.GetCookies(requestUri);

            Assert.That(actualCookies.Count, Is.EqualTo(3));
            Assert.That(actualCookies, Has.Member(expectedCookies[0]));
            Assert.That(actualCookies, Has.Member(expectedCookies[1]));
            Assert.That(actualCookies, Has.Member(expectedCookies[2]));
        }