Evolution of a hand rolled fake – part 5

As you may know if you followed my blog before; I like to roll my own fake. For interfaces it is pretty straight forward with explicit implementation of the interface and properties with delegates for implementation. Read more here.


The 7th impossible thing – Tests for tests

A couple of weeks ago I had just read Dan North’s article about how he saw six things he thought he would never see because they were impossible. I had no idea I would myself see the seventh impossible thing just a few days later. Read more here.


"Mocks: the code smell"

So I stole the title from this talk: [View:https://www.youtube.com/watch?v=Giqewl1zT_A] I have seen Arlo argue for his tests with simulators and I’ve always felt I shared his view on mocks. Or at least I share what I think is his view; that they should be avoided and only used under special circumstances. Kind of like nuclear…


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…


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…


TestInitialize execution order

This was brought to my attention and I was blown away by the fact that somebody would mark classes as TestClass without any tests in them just to reuse some setup code. And that they then make any assumptions on in which order the methods are called. If you really want to do that the…


Listening to port 80 without being admin

If you’re writing integration or so called end-to-end tests for web services you typically need to spin up a service locally just for a few tests. Or maybe you’re just interested in doing some manual testing locally. In both cased you likely need to be an administrator to be able to listen to the desired…


Stress testing with Fiddler

If you’re developing REST based services, Fiddler should not be news to you. But there might be a little trick you can use to do some simple stress testing. If you select one or more sessions in the Web Sessions pane and then hit shift+R you get a little dialog asking for number of times…


Evolution of a hand rolled fake – part 4

Another hard problem when it comes to creating fakes is when the interface contain overloads (i.e. same method name but different parameters) like this: 1: public interface IYetAnotherInterface 2: { 3: int DoSomething(); 4: int DoSomething(int x); 5: } The Fakes utility in VS11 will generate properties like DoSomethingInt32 and DoSometingInt32Int32. Not great names IMHO….


Evolution of a hand rolled fake – part 3

So how do I fake an interface with properties? 1: interface IAnotherInterface 2: { 3: int SomeProperty { get; } 4: int SomeOtherProperty { get; set; } 5: } Most of the time I just let my fake have the property implemented. This works most of the time but only really well if the interface…