mardi 3 mars 2015

Is it possible to create a dynamic unit test?

I currently have some tests running, which ensure, that for every class implementing a specific interface, I got some things respected.


This is currently running in a winform application, which allow me to give a result for every class, if they are ok or if something is wrong.


I would like to transform this into a TestClass/TestMethod, but I currently don't see how.


The issue is that I need to get a results for every class(or at least have an error for each individual class which is not working.


Currently I've this piece of code:



foreach (Type type in GetTypesToCheck())
{
m_logger.Debug("Checking type " + type.FullName);
FieldInfo staticField;
dynamic definition;
if (CheckStaticField(type, out staticField) && CheckDefinitionPresent(type) && CheckParentDefinition(type, staticField, out definition) && CheckRegistration(type, definition) &&
CheckSubTypes(type, definition))
{
m_logger.Information(type.FullName + ": OK");
}
}


Is there a way to make this kind of check with UnitTests and having one result per class(or multiple results for every class)?






Aucun commentaire:

Enregistrer un commentaire