public void SimpleGETTest() { Server s = new Server(new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }), "/", PhysicalPath, _port); s.Start(); WebClient helper = new WebClient(); string data; try { data = helper.DownloadString("http://localhost:" + _port + "/default.aspx"); } catch { s.Stop(); throw; } Assert.AreEqual(false, string.IsNullOrEmpty(data)); s.Stop(); }
public void RootDirectoryRequestTest() { using (Server s = new Server(new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }), "/", PhysicalPath, _port)) { s.Start(); string data = GetPage(string.Format("http://localhost:{0}/", _port)); Assert.AreEqual(false, string.IsNullOrEmpty(data)); s.Stop(); } }
public void SimpleWSCallTest() { using (Server s = new Server(new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }), "/", PhysicalPath, _port)) { s.Start(); using (WebService ws = new WebService()) { ws.Url = string.Format("http://localhost:{0}/WebService.asmx", _port); string response = ws.HelloWorld(); Assert.AreEqual("Hello World", response); } s.Stop(); } }
public void PrimitiveTypeWSCallTest() { using (Server s = new Server(new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }), "/", PhysicalPath, _port)) { s.Start(); using (WebService ws = new WebService()) { ws.Url = string.Format("http://localhost:{0}/WebService.asmx", _port); int result = ws.DoAdd(4, 7); Assert.AreEqual(11, result); } s.Stop(); } }
public void SimplePostTest_aspxRenderTest() { Server s = new Server(new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }), "/", PhysicalPath, _port); s.Start(); try { string data = GetPage("http://localhost:" + _port + "/SimplePostTest.aspx"); Console.WriteLine(data); Assert.AreEqual(true, data.Contains(_doPostbackJS)); } finally { s.Stop(); } }
public void Default_aspxRenderTest() { Server s = new Server(new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }), "/", PhysicalPath, _port); s.Start(); try { string data = GetPage("http://localhost:" + _port + "/default.aspx"); Console.WriteLine("received HTML:"); Console.WriteLine(data); Assert.AreEqual(true, data.Contains(_defaultASPX)); } finally { s.Stop(); } }
public void ResponseRedirectTest() { using (Server s = new Server(new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }), "/", PhysicalPath, _port)) { s.Start(); string expectedPage = GetPage("http://localhost:" + _port + "/RedirectHome.aspx"); Assert.AreNotEqual(null, expectedPage); HttpWebResponse response = GetPageResponse("http://localhost:" + _port + "/RedirectHome.aspx") as HttpWebResponse; Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Stream stream = response.GetResponseStream(); byte[] buffer = new byte[response.ContentLength]; stream.Read(buffer, 0, (int)response.ContentLength); string actualPage = Encoding.UTF8.GetString(buffer); Assert.AreEqual(expectedPage, actualPage); s.Stop(); } }
protected string GetServerVariable(string variable, string virtualDir) { Server s = new Server(new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }), virtualDir, PhysicalPath, _port); s.Start(); string data = ""; string url; if (virtualDir == "/") url = "http://localhost:" + _port + "/GetServerVariable.aspx?var=" + variable; else url = "http://localhost:" + _port + virtualDir + "/GetServerVariable.aspx?var=" + variable; try { data = GetPage(url); } finally { s.Stop(); } return data; }
public void SimplePostTest() { using (Server s = new Server(new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }), "/", PhysicalPath, _port)) { s.Start(); string url = string.Format("http://localhost:{0}/PostTest.aspx", _port); string guid = Guid.NewGuid().ToString(); NameValueCollection values = new NameValueCollection(); values.Add("txtName", guid); string page = PostValues(url, values); Console.WriteLine(guid); Console.WriteLine(page); Assert.AreEqual(true, page.Contains(guid)); s.Stop(); } }
public void CycleTest() { Server s = new Server(new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }), "/", PhysicalPath, _port); s.Start(); s.Stop(); }
public void VirtualDirectorySubDirectoryRequestTest() { using (Server s = new Server(new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }), "/vDir", PhysicalPath, _port)) { s.Start(); string page = GetPage(string.Format("http://localhost:{0}/vDir/SubFolder/", _port)); Assert.AreEqual(true, page.Contains("Hello World")); s.Stop(); } }
public void PathInfoTest() { using (Server s = new Server(new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }), "/", PhysicalPath, _port)) { s.Start(); string url = string.Format("http://localhost:{0}/Tail.aspx", _port); Console.WriteLine("Getting: " + url); string page = GetPage(url); Console.WriteLine(page); Assert.AreEqual(true, page.Contains("<span id=\"lblTail\"></span>")); url = string.Format("http://localhost:{0}/Tail.aspx/foo", _port); Console.WriteLine("Getting: " + url); page = GetPage(url); Console.WriteLine(page); Assert.AreEqual(true, page.Contains("<span id=\"lblTail\">/foo</span>")); s.Stop(); } }