The Test That Killed NUnit

It was when it came to the remove test that I was experiencing problems, a problem that shut down NUnit altogether.  The test was as below.

public void TestRemoveTasks()
{
    _tasks = new CollectionBase<TaskTest>();

    TaskTest task = new TaskTest("A", DateTime.Today);
    _tasks.Add(task);

    task = new TaskTest("B", DateTime.Today);
    _tasks.Add(task);

    task = new TaskTest("C", DateTime.Today);
    _tasks.Insert(1, task);

    //Remove the first item in the list
    _tasks.RemoveAt(0);

    Assert.AreEqual(2, _tasks.Count);
    Assert.AreEqual("C", _tasks[0].Name);

    //Remove the last item in the list, using the remove statement
    _tasks.Remove(_tasks[_tasks.Count-1]);

    Assert.AreEqual(1, _tasks.Count);
    Assert.AreEqual("B", _tasks[0].Name);
}

When I originally had the problem, I had the statement _tasks.Remove(task), and I thought that the problem was I was deleting an item that was no longer a valid reference.  Then, as I tried other things, I found that the Remove statement I have above was a problem to it.  So, to figure out what is the problem, I have to comment out several fields, and try to recreate the error.

Commenting out the first remove statement (the RemoveAt method), results in a failed test, but doesn't cause an error that exits the application, so the problem wasn't with the Remove statement.  I reversed the commenting out, and the same action occurred; it wasn't a successful test, but no crash.  So, going back to both open, then the problem occurred.

So what is it about both statements?  Nothing at all; when looking at the data that could be sent to Microsoft, I notice the problem is with another DLL, one that contains the collection.  It was causing a StackOverflowException, which was the real reason for the problem anyway, and that was crashing NUnit.

So, I made the fix to NUnit, and retried the test, and are still having problems with this one.  Nothing a little investigative work can't fix.

 

Comments

No Comments