Posts

Showing posts from August, 2016

How to unit Test Entity Framework

So, now we have the picked the best ORM for our purposes, chances are, you want to test it. We all test our code all of the time with close to 100% coverage, right? Yea, that's what I thought. Throughout the years, I've found that most developers don't test their code thoroughly because a handful of reasons: The tests written are too brittle and break with every new feature. It's too tedious to try to and mock out every little thing Its just too difficult; things are abstracted out way too much nowadays and I cant get them to pass  You know, they're not entirely wrong; I've seen code written to perform CRUD on a table that could only be described as 'awful'. Firstly, the amount of code to do that simple operation was just absurd. Secondly, the repository pattern needs to go; it just doesn't make any sense to me to try to anticipate every possible request that's needed and create a member for it (read over-complicating things). Thi