public DataSet ExampleMethod(int param1, string param2, Hashtable ht) { if(ht==null) { ht = new Hashtable(); } ht.Add('testKey','testData'); DataSet ds = new DataSet(); ds.Tables.Add(); ds.Tables[0].Columns.Add('Column1'); ds.Tables[0].Columns.Add('Column2'); ds.Tables[0].Columns.Add('Column3'); return ds ; }
this is just a example method now since i have a string ,a int and a hash table type as a input ,i can pass random values for int and string but what type of value will i pass for hash table type in order to unit test this method . and i also want a sample Nunit Fixture code for this method so that i can test it in Nunit framework .since my method returns a dataset how do i write a text fixture for it because i use AREequals.(5,add(2,3)) if it returns a int .so what to do for a method when it returns a Dataset
You can create a HashTable in the TestMethod or the TestFixture with dummy data and pass that object. Am I understanding you right?
In the [SetUp] method you populate your HashTable with dummy data.
I can see you real question is about the Assert of the returned DataSet. You can still use Assert.AreEqual, but instead test that the DataSet contain the cell data you’d expect given the HashTable.
You could use a loop for this.
Your TestMethod could look like this.
Hope that answered you question.