Book Image

Learning NServiceBus - Second Edition

By : David Boike
Book Image

Learning NServiceBus - Second Edition

By: David Boike

Overview of this book

Table of Contents (18 chapters)
Learning NServiceBus Second Edition
About the Author
About the Reviewers

Unit testing

When we were covering saga timeouts, you may have found yourself wondering just how to test something that wasn't supposed to happen for seven days, let alone an entire year!

One option would be to temporarily set all the timeouts to something so short that you could observe it before your lunch break, but this approach is problematic for several reasons. It's still hard to test this way, as you must make the timeouts long enough for you to have time to be ready and observe what happens, but short enough so that you don't get bored, zone out, and miss what it was you were trying to see in the first place. Then you're in for a world of hurt when you eventually forget to set those test values back before committing your code!

A much better approach is to take advantage of the NServiceBus testing framework, which is available through the NServiceBus.Testing NuGet package. You gain the ability to verify your long-running business processes quickly, along with all the other benefits...