O'Reilly logo

Testing with F# by Mikael Lundin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dealing with databases

The most common question when it comes to unit testing is how to remove the dependency to the database. I have already touched upon a set of techniques on how to use test doubles in order to get around dependencies, but I wanted to use this section of the chapter to take a concrete example of a database and show how to get around it.

When writing code for connecting with a database, I use the convention of isolating all database code within a module and providing that module with a signature file in order to hide its internals.

This will be demonstrated by writing an e-mail queue that is used for storing e-mails in an SQL database before sending them. This is done because the page load of a web application should not have ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required