General discussion

Locked

Erik Jacobsen

By erikjacobsen ·
Tags: Off Topic
blog root

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Comparing DataSets in Nunit-tests

by erikjacobsen In reply to Erik Jacobsen

Having a VB.NET class fetching and saving data from and to a database, I need to set up some Nunit testing.

Some methods return a DataSet, some simple values.

How do you run Nunit-tests on a database? I've come
up with these things to consider:

1) Start with an empty test-database
2) Populate with known data
3) Each test may add data when testing, but
must remove it to keep the original state
4) Write (or find) a CompareDataSet-method to
test these

I wrote a simple CompareDataSet-method myself,
and I'm about to implement the 4 things above
(or rather have someone else do it...)

We'll need to change the database connector
shortly, and a good Nunit-test should show us
if the new version works the same way.

Is this the way to do it? I'll tell you later.

Collapse -

Nunit to the rescue

by erikjacobsen In reply to Erik Jacobsen

So it worked. Actually. We had a NUnit test fail, when it wasn't
supposed to. It's never supposed to fail, of course, but it can be
unexpected. Turned out that we had missed an "ORDERED BY" clause.<br />
<br />
In MSSQL primary keys are usually clustered, meaning more or less that
selects will always return the records ordered by the primary key. Not
so in MySql, which requires you to add the "ORDERED BY". A lesson for
the future: it's best to specify your ordering, even if the default is
fine. Any decent SQL will optimize it away if it's not needed, and you
will get portable code.<br />

Back to After Hours Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums