Testing ASP.NET MVC Routes (Both Web and API)

Lately, I was working on an ASP.NET MVC web application, and one of the questions that came up to me was: How do you deal with the application’s routing table when it comes to Unit Testing and Test-driven Development?

Routing is one of the areas of your application that can easily be screwed up – and these errors then have a high likelihood to go unnoticed and make it into production. And because even small to mid-size web projects will have dozens or even of hundreds of possible URLs I find it important to have a quick and reliable strategy to deal with such a scenario (covering a bulk of URLs through tests).

Read More

A Handy IIS Express (Test) Helper Class

Oftentimes, when developing or integration-testing a piece of software that is web-based (for example a web site or a web service component such as an Azure Mobile Service), being able to start and stop a web server programmatically on an as-needed basis comes in very handy.

This is where IIS Express comes into play. IIS Express basically is a lightweight, self-contained version of his big sibling, the fully fledged Internet Information Server. Because it doesn’t run as a service and doesn’t require administrator rights, it is ideally suited for developing and testing web sites and services locally – just like Visual Studio starts an instance of IIS Express when you hit F5 on a web application/service.

This post presents a helper class to programmatically interact with the IIS Express web server.

Read More

Code Readability is soo Important…

Always write your code in a way that the next developer maintaining your code could be an axe swinging madman who knows where you live.
An unknown programmer (hopefully still alive and well…)

Clean code is simple and direct. Clean code reads like well-written prose. Clean code never obscures the designer’s intent but rather is full of crisp abstractions and straightforward lines of control.
Grady Booch

For almost ten years now, I’m a freelancer in the field of software development. Effectively, I’m something like a well-paid stand-by man who almost always is supposed to work with an already existing codebase that needs to be extended or treated in some other way (e.g. refactored or covered with tests). An important part of the job is to quickly get familiar with this codebase – it’s the single key factor for my professional success. And to succeed, I’m reliant on the code being carefully crafted and not holding any surprises. That’s why I’ve come to value well-written code really high over the years.

Read More

An introductory presentation about testing with MSTest, Visual Studio, and Team Foundation Server 2010

Note
I originally wrote this post back in February 2011 over at my old blog at geekswithblogs.net. Because it still receives some hits, I decided to take it with me and copied it to my new blog. With the exception of some necessary HTML polishing, this article is unchanged compared to its previous version.

While it was very quiet here on my blog during the last months, this was not at all true for the rest of my professional life. The simple story is that I was too busy to find the time for authoring blog posts (and you might see from my previous ones that they’re usually not of the ‘Hey, I’m currently reading X’ or ‘I’m currently thinking about Y’ kind…).

Anyway. Among the things I did during the last months were setting up a TFS environment (2010) and introducing a development team to the MSTest framework (aka. Visual Studio Unit Testing), some additional tools (e.g. Moq, Moles, White), how this is supported in Visual Studio, and how it integrates into the broader context of the then new TFS environment.

Read More

It’s the maintenance, stupid! (or: Something is rotten in developerland.)

Note
I originally wrote this post back in January 2010 over at my old blog at geekswithblogs.net. Because it still receives some hits, I decided to take it with me and copied it to my new blog. With the exception of some necessary HTML polishing, this article is unchanged compared to its previous version. – And why would I change it, anyway? I still agree with every single sentence – except the last one, for obvious reasons :-)…

Most people – even the overwhelming majority of programmers – would say that the main activity of a software developer is “writing source code”. But this is a (though quite understandable) misconception – and if you take a look at the available figures on the issue or if you – as a software professional – are honest to yourself, the misconception immediately turns out to be an enormous one.

The world is full of software systems that are already in operation, and they have to be maintained – writing a new software system from scratch is a rare highlight for most software developers. On the other hand, the importance and especially the business value of maintenance is greatly underestimated,  as well as the amount of actual working time spent on it. I think the main reason for this misperception lies in the fact that maintenance activities are spread over a much longer time span compared to the far more intense development period. Also, maintenance costs per year are relatively lower than the initial development costs.

Read More