dimanche 18 octobre 2015

How get data templates for unit tests?

I need to write a unit test for this method:

public void MethodToTest(Data data)
{
     // ... some actions with data   
}

Data class:

public class Data
{
    public string Name { get; set; }
    public int Age { get; set; }
    public string Surname { get; set; }
    // ... hundred other properties
}

In my test I need some template object of Data type to manipulate it. But this class has too many complex properties to write this "template" manually. In real program Data objects are retrieved from DB. While debugging I can serialize some of them into XML or JSON. But then I need somehow deserialize it for test. Is believe there are a common patterns and tools to solve such issues. So what is a proper way to do it?

Aucun commentaire:

Enregistrer un commentaire