Exemplo n.º 1
0
        public void op_GetResponse_HttpWebRequest_CookieContainer_whenNotFound()
        {
            var cookies = new CookieContainer();
            var request = new HttpRequest
            {
                Line = new HttpRequestLine("GET", "http://www.alan-dean.com/example")
            };

            using (var response = HttpExpectation.GetResponse(request, cookies))
            {
                Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
            }
        }
Exemplo n.º 2
0
        public void op_GetResponse_HttpWebRequest_CookieContainer_whenOnlyLine()
        {
            var cookies = new CookieContainer();
            var request = new HttpRequest
            {
                Line = new HttpRequestLine("GET", "http://www.alan-dean.com/")
            };

            using (var response = HttpExpectation.GetResponse(request, cookies))
            {
                Assert.Equal(HttpStatusCode.SeeOther, response.StatusCode);
                Assert.Equal("http://www.alan-dean.com/about", response.Headers[HttpResponseHeader.Location]);
            }
        }
Exemplo n.º 3
0
        public void op_Verify_CookieContainer_whenWrongStatus()
        {
            var cookies     = new CookieContainer();
            var expectation = new HttpExpectation
            {
                Exchange = new HttpExchange
                {
                    Request = new HttpRequest
                    {
                        Line = new HttpRequestLine("GET", "http://www.alan-dean.com/")
                    },
                    Response = new HttpResponse
                    {
                        Line = new HttpStatusLine(HttpStatusCode.OK)
                    }
                }
            };

            Assert.Throws <HttpTestException>(() => expectation.Verify(cookies));
        }
Exemplo n.º 4
0
        public void op_Verify_CookieContainer()
        {
            var cookies     = new CookieContainer();
            var expectation = new HttpExpectation
            {
                Exchange = new HttpExchange
                {
                    Request = new HttpRequest
                    {
                        Line = new HttpRequestLine("GET", "http://www.alan-dean.com/")
                    },
                    Response = new HttpResponse
                    {
                        Line    = new HttpStatusLine(HttpStatusCode.SeeOther),
                        Headers = new HttpHeaderDictionary
                        {
                            new HttpHeader("Location", "http://www.alan-dean.com/about")
                        }
                    }
                }
            };

            Assert.True(expectation.Verify(cookies));
        }
Exemplo n.º 5
0
        public void op_Verify_CookieContainer_whenWrongLocation()
        {
            var cookies     = new CookieContainer();
            var expectation = new HttpExpectation
            {
                Exchange = new HttpExchange
                {
                    Request = new HttpRequest
                    {
                        Line = new HttpRequestLine("GET", "http://www.alan-dean.com/")
                    },
                    Response = new HttpResponse
                    {
                        Line    = new HttpStatusLine(HttpStatusCode.SeeOther),
                        Headers = new HttpHeaderDictionary
                        {
                            new HttpHeader("Location", "http://www.alan-dean.com/example")
                        }
                    }
                }
            };

            Assert.Throws <HttpTestException>(() => expectation.Verify(cookies));
        }
Exemplo n.º 6
0
 public void op_GetResponse_HttpWebRequest_CookieContainerNull()
 {
     Assert.Throws <ArgumentNullException>(() => HttpExpectation.GetResponse(new HttpRequest(), null));
 }
Exemplo n.º 7
0
        public void op_Verify_CookieContainer()
        {
            var cookies = new CookieContainer();
            var expectation = new HttpExpectation
                                  {
                                      Exchange = new HttpExchange
                                                     {
                                                         Request = new HttpRequest
                                                                       {
                                                                           Line = new HttpRequestLine("GET", "http://www.alan-dean.com/")
                                                                       },
                                                         Response = new HttpResponse
                                                                        {
                                                                            Line = new HttpStatusLine(HttpStatusCode.SeeOther),
                                                                            Headers = new HttpHeaderDictionary
                                                                                          {
                                                                                              new HttpHeader("Location", "http://www.alan-dean.com/about")
                                                                                          }
                                                                        }
                                                     }
                                  };

            Assert.True(expectation.Verify(cookies));
        }
Exemplo n.º 8
0
        public void op_Verify_CookieContainer_whenWrongStatus()
        {
            var cookies = new CookieContainer();
            var expectation = new HttpExpectation
                                  {
                                      Exchange = new HttpExchange
                                                     {
                                                         Request = new HttpRequest
                                                                       {
                                                                           Line = new HttpRequestLine("GET", "http://www.alan-dean.com/")
                                                                       },
                                                         Response = new HttpResponse
                                                                        {
                                                                            Line = new HttpStatusLine(HttpStatusCode.OK)
                                                                        }
                                                     }
                                  };

            Assert.Throws<HttpTestException>(() => expectation.Verify(cookies));
        }
Exemplo n.º 9
0
        public void op_Verify_CookieContainer_whenWrongLocation()
        {
            var cookies = new CookieContainer();
            var expectation = new HttpExpectation
                                  {
                                      Exchange = new HttpExchange
                                                     {
                                                         Request = new HttpRequest
                                                                       {
                                                                           Line = new HttpRequestLine("GET", "http://www.alan-dean.com/")
                                                                       },
                                                         Response = new HttpResponse
                                                                        {
                                                                            Line = new HttpStatusLine(HttpStatusCode.SeeOther),
                                                                            Headers = new HttpHeaderDictionary
                                                                                          {
                                                                                              new HttpHeader("Location", "http://www.alan-dean.com/example")
                                                                                          }
                                                                        }
                                                     }
                                  };

            Assert.Throws<HttpTestException>(() => expectation.Verify(cookies));
        }