How to unit test a Dataset?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RBScheer

    How to unit test a Dataset?

    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
  • rowe_newsgroups

    #2
    Re: How to unit test a Dataset?

    On Jul 13, 3:04 pm, RBScheer <rbsch...@my-deja.comwrote:
    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]

    Comment

    Working...