I am a .Net developer coding in C#, and I have been assigned to a project that its manager wants it to be thoroughly unit tested, mostly emphasising isolation so that one logical bug ideally fails one test, and there are no dependencies between tests.
Today we are discussing testing patterns, and the following question has arised:
Lets say we have an object named MyHashTable
, that implements:
void Add(string key, string value);
string GetValue(string key);
We want to test each of those methods independently. The main problem of course, logically we can't get what we never added, and we can't verify something was added without getting it. We have heard and read about stubbing/mocking and other techniques that might help overcome this issues, but can't decide which solution would be most readable and maintanable.
Therefore I ask for advices/ideas how to test those methods in isolation, and if you may, include pros and cons for your suggestion. Thank you!