Latest posts

How to unit test a repository that uses DbContext with NSubstitute

A fairly standard set up for me is to have a solution in which I have a Data project that contains an EF6 .edmx file, generated from an existing database. I then split the entities into a separate Entities project, and have a Repositories project that references them both.

The problem was, I wanted to write unit tests against the code, but couldn't work out how to do it. This post shows what didn't work, and then what did.

Implementing a testable "Are you sure?" pop-up in MVVM

Implementing a testable "Are you sure?" pop-up in MVVM

A few years ago, I blogged about how to implement an "Are you sure" pop-up in MVVM. Well, I've grown up (a bit) since then, and realised that the code there wasn't testable. I therefore take great pleasure in presenting for your delight, a testable "Are you sure" pop-up in MVVM. Aren't I kind :)

Being good boys and girls, we want to write testable code, so if by some miracle we ever get around to writing unit tests, we can run them safe in the knowledge that they stand a fetid dingo's kidney's chance of working! One of the main issue involved here is ensuring we keep all view-related code out of the view model.

This post explains how to do it (with some pointless pictures)

Project Euler - Problem 14 Longest Collatz sequence, or "What I didn't learn from problem 8"

As my regular reader will doubtless remember, I recently blogged about the important lesson I learnt while solving problem 8 . I prophetically commented there...

"So, am I going to contemplate my problem domain before diving in and coding next time? Probably not, but at least if I don't, I might have some idea where to look when the bug reports come in!"

Hmm, I thought I was joking! Well, sadly I wasn't.