Appendix 2: Advanced Mocking Scenarios

This book has numerous examples of straightforward mocking scenarios. And the good news is, in a clean code environment, implementing most of those mocking requirements will be easy.

However, there are times when you have to innovate a bit to be able to mock your desired class. I did not want to end this book without presenting you with a scenario, so here you go.

In this appendix, we will experience how to combine a fake with a mock to deal with a .NET class called HttpMessageHandler. By the end of this appendix, you will be familiar with more NSubstitute functionalities and ready to tackle more advanced mocking cases.

Technical requirements

The code for this chapter can be found at the following GitHub ...

Get Pragmatic Test-Driven Development in C# and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.