How would I test a WebAPI controller

Kind of related to my previous post, this article on how to test ASP.Net WebAPI controllers made me think. As you can see from the article it is fairly easy to get your controller under test, but it does take some work to get everything setup properly. And I have never tested my WebAPI controllers…

1

If it is hard to test, you did something wrong

I’ve often been asked questions like how would you test this or been told that there cannot be unit test for some code because it is impossible to test. Well, my opinion is that if something is hard to test it is all your fault. You designed it, you implemented it and hence it is…

2

Collection initializers not doing what you expect

Let’s assume that you have a class that have a collection property and that you want the default for that collection to be to actually have a value. That class might look like this: 1: class Foo 2: { 3: public Foo() 4: { 5: this.Numbers = new List<int> { 4711 }; 6: } 7:…

1

Task-based Asynchronous Pattern – kick starter

Regardless of if you are new to TAP (Task-based Asynchronous Pattern aka “async/await”) or have been doing it for a while this presentation from an MVP summit in February (2013) serves both as a good introduction explaining how it works as well as providing deeper knowledge and high-lighting a few common problems. It’s a short presentation so definitely…

0