예제 #1
0
        ////[Test]
        public void TestHttpHandlerWritesCorrectResponse()
        {
            using (var simulator = new HttpSimulator("/", @"c:\inetpub\"))
            {
                simulator.SetFormVariable("username", "phil")
                .SetReferer(new Uri("http://example.com/1/"))
                .SimulateRequest(new Uri("http://localhost/MyHandler.ashx?id=1234"));

                var handler = new TestHttpHandler();
                handler.ProcessRequest(HttpContext.Current);
                HttpContext.Current.Response.Flush();

                const string expected = @"c:\inetpub\MyHandler.ashx:phil:1234:http://example.com/1/";
                Assert.AreEqual(expected, simulator.ResponseText, "The Expected Response is all wrong.");
            } //HttpContext.Current is set to null again.
        }
예제 #2
0
    	////[Test]
        public void TestHttpHandlerWritesCorrectResponse()
        {
            using (var simulator = new HttpSimulator("/", @"c:\inetpub\"))
            {
                simulator.SetFormVariable("username", "phil")
                    .SetReferer(new Uri("http://example.com/1/"))
                    .SimulateRequest(new Uri("http://localhost/MyHandler.ashx?id=1234"));

                var handler = new TestHttpHandler();
                handler.ProcessRequest(HttpContext.Current);
                HttpContext.Current.Response.Flush();

                const string expected = @"c:\inetpub\MyHandler.ashx:phil:1234:http://example.com/1/";
                Assert.AreEqual(expected, simulator.ResponseText, "The Expected Response is all wrong.");
            } //HttpContext.Current is set to null again.
        }
예제 #3
0
        // //[Test]
        public void CanSimulateFormPost()
        {
            using (var simulator = new HttpSimulator())
            {
                var form = new NameValueCollection {
                    { "Test1", "Value1" }, { "Test2", "Value2" }
                };
                simulator.SimulateRequest(new Uri("http://localhost/Test.aspx"), form);

                Assert.AreEqual("Value1", HttpContext.Current.Request.Form["Test1"]);
                Assert.AreEqual("Value2", HttpContext.Current.Request.Form["Test2"]);
            }

            using (var simulator = new HttpSimulator())
            {
                simulator.SetFormVariable("Test1", "Value1")
                .SetFormVariable("Test2", "Value2")
                .SimulateRequest(new Uri("http://localhost/Test.aspx"));

                Assert.AreEqual("Value1", HttpContext.Current.Request.Form["Test1"]);
                Assert.AreEqual("Value2", HttpContext.Current.Request.Form["Test2"]);
            }
        }
예제 #4
0
       // //[Test]
        public void CanSimulateFormPost()
        {
            using (var simulator = new HttpSimulator())
            {
                var form = new NameValueCollection {{"Test1", "Value1"}, {"Test2", "Value2"}};
                simulator.SimulateRequest(new Uri("http://localhost/Test.aspx"), form);

                Assert.AreEqual("Value1", HttpContext.Current.Request.Form["Test1"]);
                Assert.AreEqual("Value2", HttpContext.Current.Request.Form["Test2"]);
            }

            using (var simulator = new HttpSimulator())
            {
                simulator.SetFormVariable("Test1", "Value1")
                    .SetFormVariable("Test2", "Value2")
                    .SimulateRequest(new Uri("http://localhost/Test.aspx"));

                Assert.AreEqual("Value1", HttpContext.Current.Request.Form["Test1"]);
                Assert.AreEqual("Value2", HttpContext.Current.Request.Form["Test2"]);
            }
        }