• .NET Mobile

    Poor man's ASP.NET testing

    August 25, 2005 Share
    Sometimes you have a simple page with some web controls on it.  You would like to have a simple way to make sure that the text of a status message is exactly the one you expect.  Well, it turns out that the .NET class library has a real gem that can help you.  The System.Net.WebClient class helps you request pages, post data, upload files with a simple interface.  Getting the page contents is easy: [Test]public void GetPage(){   WebClient client = new WebClient();   using (Stream dataStream = client.OpenRead(pageAddress))   {      XmlDocument document = new XmlDocument();      document.Load(dataStream);       XmlNode label = document.SelectSingleNode("//label[@id='nameLabel']");      Assert.AreEqual("Name:", label.InnerText);   }} I have taken some extra care to return valid XML,...