Testing Dependencies
One great thing about passing in dependencies like this is that it makes the core functions very easy to test because it’s easy to provide fake, but working, dependencies without any need for a special mocking library.
For example, say that we want to test whether the product code aspect of the validation is working. One test should check that if the checkProductCodeExists succeeds, the whole validation succeeds. And another test should check that if the checkProductCodeExists fails, the whole validation fails. Let’s look at how to write these tests now.
Here’s a tip before we start: F# allows you to create identifiers with spaces and punctuation in them, as long as they are enclosed in double-backticks. It’s not a good ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access