My (not-so sh*tty) engineering philosophy

November 18, 2014


Get sh*t done Do sh*t right Just do it Own your sh*t Know your sh*t Give deep sh*t Have a backlog of sh*t Enable others to leverage your sh*t Keep up with the sh*t around you Always be learning new sh*t DO EPIC SH*T

Posted in: General

Raising events in NMock

March 4, 2009


It is actually pretty easy to raise events using the latest release of NMock. You can basically use Expect.Once.On(bla).EventAdd(“SomeEvent”, Is.Anything) to specify that you expect an event handler to be added for “SomeEvent” event on bla object and fire that event using Fire.Event(“SomeEvent”). Here’s an example, minus any domain noise, that demonstrates the whole thing.

Posted in: .NET

Interfaces and partial classes

February 13, 2009


What will happen when the following piece of code is compiled? Options: Compiler error. “Moved” will be printed.

Posted in: .NET

Preventing tracing of sensitive information in logs generated using .NET trace classes

December 17, 2008


If you have an application that deals with payment processing, social-security numbers, etc., there’s a possibility that such sensitive information can be written to log by a component in the application. While you need to take appropriate measures to ensure that the log files are sufficiently protected, you may also want to prevent such information […]

Posted in: .NET

Mocking functions taking variable number of args using C# params keyword

December 16, 2008


Consider the following interface that takes a variable number of arguments in its Add method. And consider that we have to test the following function which invokes Add with two arguments. The expectation created below is incorrect: It will cause NMock to generate the following exception because NMock is expecting two distinct arguments to Add […]

Posted in: .NET

Fluently mocking fluent APIs

December 15, 2008


The best thing about fluent-style APIs is that they are readable and flow easily. Consider the following for example: The API used above is clearly more readable than: Another reason I like them is that fluent style APIs are easier to pick up. You can rely on intellisense to guide you more as you have […]

Tagged: ,
Posted in: .NET

Testing methods that depend upon a singleton class

December 11, 2008


Singleton is probably one of the most (mis-)used design patterns. In this article I intend to lay out a scenario and then demonstrate how we can go about testing methods that depend upon a singleton class. Finally I’ll recap the whole approach in a bulleted list for easy reference. Let’s restrict our problem to involve […]

Posted in: .NET

Get every new post delivered to your Inbox.