samedi 12 septembre 2015

How to unit test asp.netweb forms

I have a asp.net app that you upload a xml filenusing the fileupload control, and it is parsed into a list of objects and displayed in a grid view pretty simple stuff. but I have been asked to write some unit tests. Im new to tdd and would like sum advice on how to write some unit tests.

This is what I have so far. Which I hard coded the xml file. Is there a way to unit test for the fileupload

       [TestClass]
public class UnitTest1
{

     string source = @"C:\Users\\Desktop\Web Application\ Web Application.Tests\LunchTest.xml";


    [TestMethod]
    public void ParseXmlTest()
    {
        XmlUlitilyClass x = new XmlUlitilyClass();

        Assert.AreEqual(x.ParseXml(source).Count, 4);
        Assert.AreEqual(x.ParseXml(source)[3].Name,"Roast of the day");
        Assert.AreEqual(x.ParseXml(source)[3].DesertIncluded, true);
        Assert.AreEqual(x.ParseXml(source)[0].Calories, 350);
        Assert.AreEqual(x.ParseXml(source)[1].Vegetarian, false);


    }
}

Aucun commentaire:

Enregistrer un commentaire