tags:

views:

195

answers:

1

My project generates a few values (equal partitioning method) for each data type by getting the minimum and maximum values. I am generating these values for functional testing, I am actually passing these values to nunit partner, max amd min are applicable to int, float, double etc.. These values are test data.

Initially I generated them for basic data types like int, float, double, string etc..

Now I need to support data types like DataSet, HashTable and other Collections.

public DataSet MySampleMethod(int param1, string param2, Hashtable ht)

For testing this fuction I can pass values for int and string, but how will I pass test data for ht or how is test data generated for a hash table?

+2  A: 

You need to abstract the hash table implementation out of the code so that it can be mocked, injected or stubbed when unit testing.

Just create an interface called IHashTable and then create your concrete implementation by implementing the interface. Then make all your classes that use hashtables now use IHashTable. Then add a parameter to their constructors to which accepts an IHashTable.

Then when you're unit testing pass in a mock or stub of the IHashTable interface.

Mocking: http://en.wikipedia.org/wiki/Mock_object

Jonathan Parker
is there any open source tool for creating stubs
Arunachalam
RhinoMocks is open source
Grzenio
any you suggest some examples for the above answer
Arunachalam
an u give example for the above answer
Arunachalam