Book Image

ServiceStack 4 Cookbook

Book Image

ServiceStack 4 Cookbook

Overview of this book

Table of Contents (18 chapters)
ServiceStack 4 Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Unit testing ServiceStack applications


In this recipe we'll focus on simple techniques to test individual units of code within a ServiceStack application. We will use the ServiceStack testing helper BasicAppHost as an application container, as it provides us with some useful helpers to inject a test double for our database. Our goal is small; fast tests that test one unit of code within our application.

Getting ready

We are going to need some services to test, so we are going to use the PlacesToVisit application. If you are starting your own project from the beginning, refer to Creating a ServiceStack solution with Visual Studio and NuGet in Appendix A, Getting Started for information on how to get ready with Visual Studio and ServiceStack. This also covers basic usage of NUnit, the unit testing framework we will be using in this recipe.

How to do it…

  1. Create a new testing project. It's a common convention to name the testing project <ProjectName>.Tests—so in our case, we'll call it PlacesToVisit...