Christian Specht
Christian Specht

Reputation: 36431

How to unit test a conversion library?

I'm just starting out with unit testing in C#.
I have been reading about unit testing for a long time now, and I've already been playing around with NUnit, but this is the first time that I actually try to write real tests for real code.

But my problem is:
I'm having a hard time to come up with things that I can actually test.

The project I want to test is a conversion library (to convert lists of POCOs to ADO Recordsets).

So far, I've come up with only two things to test:

So, my questions are:

Upvotes: 3

Views: 1045

Answers (3)

Chaitanya
Chaitanya

Reputation: 5293

Try the Pex tool from Microsoft. It generates Unit tests after analyzing your code. Just a quick install of Visual studio plugin. Then Right click the class/method you want to test and in the context menu get Pex to generate all the possible code paths for you.

Upvotes: 0

Reed Copsey
Reed Copsey

Reputation: 564433

There are quite a few things to test. I would also suggest thinking about and potentially verifying:

  • Private fields of POCO don't map through correctly
  • Invalid entries in the list throw exceptions correctly
  • Recordset length is correct
  • Inheritance in POCO is handled as desired (ie: base class members map through as expected)

Upvotes: 3

Matt Fenwick
Matt Fenwick

Reputation: 49095

Add a conversion test case where you know the exact input and output. Then test that the code produces that answer exactly.

Upvotes: 1

Related Questions