I have a simple method, which takes an IEnumerable of an object and export that as an Excel workbook. The object could be something like a student (to use the classic example).
public class Student
{
public string Name { get; set; }
public int Age { get; set; }
public int StudentId { get; set; }
}
And then the method I need to test
public void ExportStudents(IEnumerable<Student> students)
{
// This method will save the students to an Excel workbook with a known name
...
}
I would like some sort of test of this, but the best I can come up with is a console application that you can run manually, something like this:
public void Main()
{
var students = new List<Student>
{
{ Name = "John Doe", Age = 19, StudentId = 1 },
{ Name = "Max Power", Age = 21, StudentId = 2 },
...etc
}
// Export the list as a workbook
WorkbookExporter.ExportStudents(students);
}
And then inspect the workbook manually. But this seems like a very slow and primitve way of testing. How do you test something like this - or to take another example, something sending an e-mail - in a smarter way?
Aucun commentaire:
Enregistrer un commentaire