mardi 29 mars 2016

How to make a Unit test with several data sources?

guys I have a method and I want to test it with two data sources (two lists in my case). Can someone help and explain how to make it right? Should I use attribute TestCaseSource and how?

 public void TestMethodIntToBin(int intToConvert, string result)
    {
        Binary converter = new Binary();
        string expectedResult = converter.ConvertTo(intToConvert);
        Assert.AreEqual(expectedResult, result);
    }

public List<int> ToConvert = new List<int>()
    {
        12,
        13,
        4,
        64,
        35,
        76,
        31,
        84
    };
    public List<string> ResultList = new List<string>()
    {
        "00110110",
        "00110110",
        "00121011",
        "00110110",
        "00110110",
        "00100110",
        "00110110",
        "00110110"
    };

Aucun commentaire:

Enregistrer un commentaire