Unit testing caveats

There is much controversy regarding test driven development. People do not seem to settle on the time trade-off, the London vs. State school, TDD vs BDD and the list could go on. But before diving into all of these, my first reports from the tranches of unit testing are as follows.

Behavior depending on date and time conditions

Tests should be runnable at any hour. Even if we leave the office at 6PM and everything seems to work properly, having loose DateTime variables in the tests could mean that they will fail during the automatic build that is run every night.

For example, we might want to ensure that our newsletter goes out only on Mondays. In this case, using an ICommand would make sense, because we can verify that our condition has been met before executing the action. A Command accepts a CanExecute Action that could like this one:

Func<Email, bool> canSendEmail = (email) =>
    if (email.DateToBeSent.DayOfWeek == DayOfWeek.Monday)
        return true;
    return false;

Continue reading

Get started with MonoGame in 5 easy steps

MonoGame is the little brother of Mono: a small and cool platform for making (mostly) 2D games. It’s an open source implementation of XNA and is compatible with iOS, Android, Mac, MacOS, Linux and Windows 8 (support for more platforms is coming). If however, more complex and 3D games is your thing, you can head out to Unity3D, also in the Mono family.

1. Get MonoGame from CodePlex

Download the latest MonoGame version from Codeplex. The is are multiple versions: a Windows one, a MonoDevelop one and, finally, the one we need, the Xamarin version. They each come as an .mpack, which needs to be installed in the corresponding IDE.
Continue reading

TeaTimer for Mac

This article will cover how to build a Mac application with Mono.Mac, making use of XCode interface builder and NSComboBoxDataSource. TeaTimer will let us chose a tea variety and it will the time how long it will take to make it.

Open Xamarin studio and start a new project. Select a Mono.Mac application.

Screenshot 2013-10-26 17.00.57

Open the MainWindow.xib, which will be our main application window. This will start up XCode interface builder. From the Object library, drag and drop onto the existing window:

  • a combo box, which will display our tea menu,
  • a button, to start the timer,
  • two labels: one for displaying the current time and one for additional information

Continue reading

How to open multiple instances of Xamarin Studio on a Mac

Normally, Xamarin Studio does not allow multiple solutions being open. You can, however, open multiple instances of Xamarin Studio.

You can type in your terminal the following command:

open -n /Applications/"Xamarin Studio.app" 

This works fine if you need this once, but if you find that you will be doing this on a regular basis, follow the steps below:

Continue reading