CCD
Unit Tests – The Rent Is Too Damn High
On 06, Feb 2011 | inAOP | vonJohannes Hoppe
Faking System.DateTime.Now
For sure: The rent is too damn high!
And if we are writing Unit Tests, we are often paying a damn high price, too! Let’s look at a inconspicuous property that every .NET programmer is using:
System.DateTime.Now
Getting the current time is really easy. But how can we mock that statement for our tests?!
Solution 1
The first solution would be the usage of our favorite dependency injection framework. We would write a wrapper for DateTime.Now and produce an interface like this:
public interface IDateTime { DateTime Now { get; } }
FindStackOverlowAttribute vs. StackOverlowException
On 19, Jan 2011 | inAOP | vonJohannes Hoppe
StackOverlowExceptions caused by recursive calls are evil bugs.
While developing on your local machine you have a high chance to jump right into the buggy line of code by attaching Visual Studio to the process. I’m talking about ASP.NET websites, so in my case it’s the w3wp.exe process.
But as soon as your code goes live your debugging possibilities are limited. Of course, you can do remote debugging with Msvsmon.exe, but you still need to know where to look at.* It’s a fact: Software-Bugs successfully hide themselves from developers. So as long as you hunt them, they won’t appear. Instead they like it to scare principals or end customers. For obvious reasons these peoples won’t provide you with a Strack Trace that could help you.
Lesson 07 – Continued: Unit Testing in Detail
On 01, Dez 2010 | inRIA lecture | vonJohannes Hoppe
We are going to continue with the slides from last lecture.
I will give you a lot of space for questions and to conduct experiments with your code!