Testing

Dependency Injection of AppSettings in ASP.NET Core

December 30, 2021 in Dependency Injection Testing
Read Time: 5 minutes
Dependency Injection of AppSettings in ASP.NET Core
When talking about the Dependency Inversion Principle, the D in SOLID, we have a pretty good idea of what dependencies we’re trying to abstract away. OrderRepository or SendGridEmailClient are easy examples of implementations we should abstract away. It also overlaps well with the Single Responsibility Principle, since data access for orders and sending emails are separated from the business logic where they are used. The C# implementation of this would involve making these classes implement the appropriate interfaces, e.
Read more...

Mocking Entity Framework 6 - How To Do It, When NOT To Do It

December 16, 2021 in Testing TDD Entity Framework
Read Time: 8 minutes
Mocking Entity Framework 6 - How To Do It, When NOT To Do It
Introduction First off, let me make a few assumptions if you’re reading this article and trying to mock with Entity Framework 6: You’re on a legacy codebase. If you weren’t you’d be using Entity Framework Core and the In-Memory Provider. You’re not utilizing Database Migrations. If you were, it may probably be easier to create a new database and run tests using localDb. Your schema is extremely large. With a large database schema (often seen in legacy systems) data setup can become extremely difficult.
Read more...

Zero Tests to TDD - What I've Learned

July 26, 2020 in Testing TDD Entity Framework
Read Time: 10 minutes
Zero Tests to TDD - What I've Learned
A Little Background I’m usually a stickler for best practices, but automated testing is something that has eluded me in my professional career for a long time. I typically work on legacy, line of business applications. So automated testing was never a priority. I’ve tried and failed to introduce various development teams to automated testing. Legacy applications are inherently difficult to test. Most everything I’ve read about automated testing points to trivial examples of testing and something like add (1, 2) and making sure the output was 3.
Read more...