Unit Testing and the Microframework

So I started writing some real code to handle the PWM signals coming into the Netduino from a RC receiver.  The simple code that I had has quickly  morphed into a jumbled mess of spaghetti code:


I stopped writing code and decided that this ripe for some unit testing.  I added a unit test project to my solution but I got this:


Sure enough:


This is the same problem I had with my Windows Phone app.  Instead of giving up on unit testing (which is what I did with my WP app, and now I am regretting it), I decided to take a separate approach.  I first thought of using a testable .dll that has the code for the Netduino app but I ran into the same problem:


So I need to create a test harness for my code in the Microframework.  Fortunately, when I googled that on bing, I found this great article.

Instead of adding a reference to the Microframework, I Added As Link to the class I want to test:


I can then test the methods in the class.

The problem with this way of testing is that if the class under test references other assemblies or services, those assemblies need to be referenced in the testing project.  What happened is that my testing project quickly became bloated and violated the Law Of Demeter.

I wonder if MSFT will come out with a testing framework for both the Microframework and/or the PCLs…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: