Unit testing multi threaded code–Timers

Writing unit tests for multi-threaded is not simple and could even be impossible for some scenarios – how could you test that an asynchronous method was not called?Since most unit testing examples tend to be rather trivial I’ve decided to try and explain other more complex scenarios – preferably without using any calculator examples.The “Timer” … Continue reading Unit testing multi threaded code–Timers

Things I learnt reading C# specifications (#1)

After reading Jon Skeet’s excellent C# in Depth - again (3rd edition - to be published soon) I’ve decide to try and actually read the C# language specification…Being a sensible kind of guy I’ve decided to purchase the annotated version which only cover topics up to .NET 4 – but has priceless comments from several … Continue reading Things I learnt reading C# specifications (#1)

Serialization and events in C#

Today I had an interesting problem:I was trying to serialize and object using BinaryFormatter but it kept on failing because some class was not Serializable. I’ve double and triple checked my class and all of it’s inner properties and verified that indeed they were marked correctly.The ProblemLooking closer at the exception I’ve noticed something – … Continue reading Serialization and events in C#

Making string based method strongly typed

I can't believe they implemented this way – was the first thought on my mind…The method in question is part of the new(er) NUnit’s constraint based model specifically the one used to assert a property value.Before we dive deeper a few words on the constraint based model:constraint based modelMost unit testing framework have similar way … Continue reading Making string based method strongly typed

Fluent interfaces in C# – method chaining

For those of you who just tuned in, this is a third post on the subject of fluent interfaces using C#. In case you haven’t read them before – here are my previous posts on the subject:IntroductionExtension MethodsRight, now that we’re familiar with fluent interfaces it’s time to move to “Method Chaining”.Method chaining is the … Continue reading Fluent interfaces in C# – method chaining