Revisiting – how to make your EF queries testable

So, some time back I spent some time agonizing around testability of code which has to talk to a database. I now think I have found a somewhat reasonable answer, which assumes that you are using some kind of LINQ query relational database mapper like EntityFramework which my samples are based on. It has these…

4

Unit Testing DbContexts and queries – the status quo

So here’s the scene. I’ve been working on unit testing for a solid day, my percent coverage is up, my code is better factored, and now I do my ‘what is the most untested class I have’ analysis one more time, and discover that it is… ‘BillingEntitiesContext’. BillingEntitiesContext is my subclassed DbContext for describing my…

3

Reflections on unit tests (and more what happened next) and introducing ashmind and his Argument NuGet package

Here are a few thoughts about the refactoring process from going through my initial unit testing iteration. Constructor Injection can make things look a lot more testable. But I think you want to be careful about jumping into this – don’t do it as the first step in refactoring. It’s probably better to first extracting…

0

Struggling with unit tests (again)

I am having a mental hard time today because of unit tests. Not tests that fail… tests that don’t exist. And tests I’m not sure that should exist. It is very natural, right, and highly necessary to test methods which do a non-trivial transformation of data. Here is an example: given a list of events,…

3