vendredi 11 août 2017

Unit test for text parser

I'm new at unit testing and I try to test my parser:

public static List<tranche> Parse22(string record)
{
    List <tranche> Tranche = new List<tranche>();
    foreach (var i in record)
    {
        var ts = new tranche();
        ts.dealer_name = line.Substring(2, 5);
        ts.invoice = line.Substring(7, 7);
        ts.amount = Decimal.Parse(line.Substring(14, 13));
        ts.vin = line.Substring(46, 17);
        ts.model = line.Substring(63, 4);
        ts.registration = line.Substring(72, 10);
        ts.brutto = Decimal.Parse(line.Substring(95, 13));
        Tranche.Add(ts);
    }
    return Tranche;
}

I want to test dealer_name and VIN are correct. But I don't understand what should be at "Assert."

[TestClass]
public class ParserTest
{
    [TestMethod]
    public void Parse_LineStarts22_ReturnsVINandDealerNameCorrect()
    {
        string record = testString;
        var res = myParser.Parse22(record);

        Assert.AreEqual() //???
    }
}

Aucun commentaire:

Enregistrer un commentaire