Month: May 2009

Testing local objects in a method using Fake objects

No Picture

I recently had a scenario where I needed to test whether calls to dependant objects were working as expected in a void method (an integration test). To do this, I constructed what is known as a Fake object,…

Read More »

Mocking with RhinoMocks

No Picture

I have recently started getting into TDD, and have begun using mocking (specifically RhinoMocks http://ayende.com/projects/rhino-mocks.aspx). Mocking is a mechanism by which you can effectively force dependencies required by a specific piece of code to behave in a certain…

Read More »

Resharper: Keymaps

No Picture

I’ve just started using resharper – i tried it a few years ago and didn’t get on with it, however I really like version 4.5 (which I’m using now). I currently use the resharper keymap, found here http://www.jetbrains.com/resharper/docs/ReSharper45DefaultKeymap2.pdf,…

Read More »

Quicknote: XmlNamespaceManager

No Picture

Just a very quick note, as i don’t use this frequently enough to remember it – when parsing xml that declares an xml namespace in it’s root element (i.e. xmlns), you must first create an XmlNamespaceManager before you…

Read More »

C#: A couple of things i didn’t know

No Picture

I should have know the following, but didn’t Object Initializers: If you have the following class: class Person {   public string Forename { get; set;}   public string Surname { get; set;} } Instead of initializing properties…

Read More »

Overriding behaviour of methods

No Picture

Below is a pattern to override the implementation of a method in a class – this is especially useful for writing unit tests, e.g. for stubbing out a method behaviour. internal class MyClass {     private readonly Func<string,…

Read More »

Quicknote: RhinoMocks

No Picture

Just a very quick and rough note – i started using RhinoMocks today, which allows you to create dummy objects when writing test code – extremely useful for simulating boundary conditions, and isolating which classes are tested. Anyway…

Read More »