I want to add a method in an interface that will execute tests which correspond to the implementing class.
Is it possible to "force" a programmer to write tests without him / her working around it?
For example:
public interface ISomeInterface
{
int SomeCalculationMethod();
IEnumerable<SomeCustomTestResult> Tests();
}
public class SomeClass : ISomeInterface
{
public int SomeCalculationMethod()
{
var someInt = 1;
var someCalculation = someInt + someInt;
return someCalculation;
}
public IEnumerable<SomeCustomTestResult> Tests()
{
var iDontWantToWriteTests = new List<SomeCustomTestResult> {
new SomeCustomTestResult {
Success = true
}
};
return iDontWantToWriteTests;
}
}
public class SomeCustomTestResult
{
public bool Success { get; set; }
}
Aucun commentaire:
Enregistrer un commentaire