How to unit test a Dataset?

R

RBScheer

Hi.

I have written unit tests for my helper classes that return simple
values as strings or integers. Now I need to test the methods that
deal with DataSets and DataTables. Is there any special issues when
running these kind of tests? I ask this because if I create a DataSet
from scratch reproducing the desired structure and compare this to the
real DataSet I got from running my helper class, the Assert.AreEqual
method says me they are not equal! But both DataSets have the same
tables, columns and number of records.

Any help would be greatly appreciated !

Regards,
RBScheer
 
R

rowe_newsgroups

Hi.

I have written unit tests for my helper classes that return simple
values as strings or integers. Now I need to test the methods that
deal with DataSets and DataTables. Is there any special issues when
running these kind of tests? I ask this because if I create a DataSet
from scratch reproducing the desired structure and compare this to the
real DataSet I got from running my helper class, the Assert.AreEqual
method says me they are not equal! But both DataSets have the same
tables, columns and number of records.

Any help would be greatly appreciated !

Regards,
RBScheer

That's a really good question, and not one that I really know an
answer for. If it were me, I'd test as much functionality as you can,
say making sure that you have rows, or a certain number of rows, and
that you have the appropriate columns. You could even spot check the
values of a few of the data rows if you like. The other option would
be to loop through the actual dataset members and compare them with
the expected dataset using Assert.IsTrue(...). That way if any of the
members don't match, the Assert.IsTrue would fail. To be honest, I'm
not sure if I like either method, but at least some coverage is better
than no coverage.

And just to be a pain, why is you are writing your tests after the
code? IMO, you should be doing it the other way around :)

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top