我有一个类,其唯一目的是从接口运行其他类的方法。
测试类的接口没有问题,但是运行程序实际上什么也没做,而且(按照现在的情况)传递到构造函数中的唯一参数被保持为私有。
在我的情况下,这些类正在将文本文件导入数据库。
测试类的接口没有问题,但是运行程序实际上什么也没做,而且(按照现在的情况)传递到构造函数中的唯一参数被保持为私有。
在我的情况下,这些类正在将文本文件导入数据库。
internal DataImporter
{
private List<IFileImporter> _importers;
public DataImporter(List<IFileImporter> importers){
_importers = importers;
public bool RunImporters()
{
//foreach importer, call its "Run" method - each one then does whatever it needs to do
//however, this need not call a specific "Run" method on IFileImporter
//I have another app that uses IFileImporter to check for presence of a file first
//then allow user to choose to import or not.
}
在我看来,这里没有什么需要测试的吧?我无法测试_importers
的值,也不想仅仅为了测试而将其公开。DataImporter是特定于此实例的,因此创建一个接口似乎没有任何益处。
我在其他地方重用了IFileImporters,但这是唯一的“批量”导入程序,其他程序需要手动从WinForms应用程序中调用,还有一些根本不在此项目中。
那么,我需要测试这个……我能对此进行什么测试呢?