It seems as if causing DateTime.Now to return another value has become the demo to show when demoing an unconstrained Mocking framework. It’s easy to show and needed in many unit tests – unless you want your tests to be affected by time – trust me and you don’t. That’s why I was amazed to … Continue reading Faking DateTime using Microsoft Fakes seems to be broken
Tag: C#
New Pluralsight course: C++ Unit Testing Fundamentals Using Catch
Last week my very first Pluralsight course went live!My course on unit testing in C++ using CATCH is ready for your viewing pleasure. It’s about a topic I’m passionate about - how to write good unit tests, I’ve used Catch because I found that it helps writing good tests while avoiding many of the pitfalls … Continue reading New Pluralsight course: C++ Unit Testing Fundamentals Using Catch
MSTest V2 – First impressions
It’s been a while since I’ve tried a new Unit Testing framework. It seemed that between NUnit, XUnit & MSTest I had enough to choose from. I’ve always tried to be pragmatic when choosing a test framework for a new project and when suggesting one to a new client. Although all .NET unit testing framework … Continue reading MSTest V2 – First impressions
Implementing Soundex using LINQ (with help from OzCode)
A while ago I came across the very interesting Soundex algorithm. It’s a way to find similarity between words based on how they sound – I’ll let Wikipedia explain:Soundex is a phonetic algorithm for indexing names by sound, as pronounced in English. The goal is for homophones to be encoded to the same representation so … Continue reading Implementing Soundex using LINQ (with help from OzCode)
Comparing Two objects using Assert.AreEqual()
Anyone who ever googled (binged?) about unit testing have heard about the “one assert per test rule”. The idea is that every unit test should have only one reason to fail. It’s a good rule that help me write good, robust unit test – but like all such rules-of-the-thumb it’s not always right (just most … Continue reading Comparing Two objects using Assert.AreEqual()
VS2015 Update 1 brings (back) parallel test execution
Yesterday I’ve installed the new VS2015 update and tried to make my machine talk to my win10 (IoT core) Raspberry PI. It didn’t help but that’s a story for another blog post – spoiler: it was a problem with my laptops Ethernet port.After the dust settled I’ve started reading about the new goodness that was … Continue reading VS2015 Update 1 brings (back) parallel test execution
Using C++ debug visualizers in VS2015
I have been using the .NET debug visualizers (and DebuggerDisplay atribute) for a long (long) time and I like the way they make my code easy(ier) to debug. Until recently I was not aware that Visual Studio has a similar capability for C++.Any C++ dev armed with Visual Studio can use XML files to create … Continue reading Using C++ debug visualizers in VS2015
How to fake a singleton in C++
When unit testing legacy code I find several (anti) patterns which prevent getting code under test. The most recurring pattern I see is the Singleton pattern – a useful pattern when not abused and overused.In the object oriented world Singleton’s are slightly better than their evil cousin – the static method. Unfortunately I’ve seen them … Continue reading How to fake a singleton in C++
Using NUnit and FakeItEasy to create fake objects automatically for your tests
From time to time I get to teach and mentor Java developers on the fine art of unit testing. There are many similarities when unit testing in Java and .NET but more interesting are the differences between the two. Faking objects in Java using MockitoOne of the well-used Java Isolation (Mocking) frameworks is called Mockito … Continue reading Using NUnit and FakeItEasy to create fake objects automatically for your tests
Visual Studio tip: paste json/xml file as class
I’m a long time listener of .NET rocks and today during my drive to work while listening to TDD on .NET and Java with Paul Mooney, Carl mentioned a cool tip I want to share with you. In the past I have use XSD.exe to create classes from XML files for serialization purposes (and similar … Continue reading Visual Studio tip: paste json/xml file as class