Posts for 16th August 2010

A recent project has required a C# based web service to update a directory server with changes it receives.

For testing the directory server chosen was OpenLDAP as shipped with Ubuntu 10.04 (Lucid Lynx).

A great little tool found for manipulating this directory was LDAP Admin.

    One of the projects I have been working on uses the nunit.mocks assembly.

    Previously this project used release 2.4.7 of NUnit. On upgrading to 2.4.8 some tests started to fail.

    It appears that the behaviour of the Expect method has subtly changed. Previously the number of times a mocked method was called was irrelevant. With 2.4.8 it now appears Expect needs to be called for each invocation.

    The following code under 2.4.7 would allow LogInformation on ILogger to be called any number of times, but under 2.4.8 would only allow it to be called once.


    internal static ILogger GetMockLogger() { DynamicMock mockLogger = new DynamicMock(typeof(ILogger)); ILogger logger = (ILogger)mockLogger.MockInstance; mockLogger.Expect("LogInformation"); return logger; }

    To allow log Information to be called twice the following code would be used:


    internal static ILogger GetMockLogger() { DynamicMock mockLogger = new DynamicMock(typeof(ILogger)); ILogger logger = (ILogger)mockLogger.MockInstance; mockLogger.Expect("LogInformation"); mockLogger.Expect("LogInformation"); return logger; }