I'm making my first baby steps with unit testing and have written (among others) these two methods:
[TestCase]
public void InsertionSortedSet_AddValues_NoException()
{
var test = new InsertionSortedSet<int>();
test.Add(5);
test.Add(2);
test.Add(7);
test.Add(4);
test.Add(9);
}
[TestCase]
public void InsertionSortedSet_AddValues_CorrectCount()
{
var test = new InsertionSortedSet<int>();
test.Add(5);
test.Add(2);
test.Add(7);
test.Add(4);
test.Add(9);
Assert.IsTrue(test.Count == 5);
}
Is the NoException
method really needed? If an exception is going to be thrown it'll be thrown in the CorrectCount
method too.
I'm leaning towards keep it as 2 test cases (maybe refactor the repeated code as another method) because a test should only test for a single thing, but maybe my interpretation is wrong.