I was testing various sorting algorithms, so I had a base class that SortTestBase
that contained actual tests and accepted the algorithm in the constructor, and derived classes that supplied the algorithm.
Resharper test runner insisted on executing tests from the “naked” base class and then complained that “No suitable constructor was found”. I fixed this by making the base class abstract
. Fortunately, Resharper test runner does not go as far as to try to instantiate abstract classes.
public abstract class SortTestBase
{
private readonly Action<int[]> _sort;
protected SortTestBase(Action<int[]> sort)
{
_sort = sort;
}
[Test]
public void EmptyArray()
{
var arr = new int[0];
_sort(arr);
CollectionAssert.AreEqual(new int[0], arr);
}
... more tests ...
}
[TestFixture]
public class QuickSortTest : SortTestBase
{
public QuickSortTest() : base(QuickSort.Sort)
{
}
}
Permalink
У тебя в ЖЖ HTML форматирование поломано (только этот post). Я смотрю в Хроме на Маке.
Permalink
Спасибо. Это он дженерики за HTML теги принял. Попробую исправить
Permalink
It is fixed now 🙂