Book Image

MASTERING NSERVICEBUS AND PERSISTENCE

By : Richard L Helton
Book Image

MASTERING NSERVICEBUS AND PERSISTENCE

By: Richard L Helton

Overview of this book

Table of Contents (15 chapters)
Mastering NServiceBus and Persistence
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Unit testing NServiceBus


Visual Studio 2012 has plenty of unit testing features. NServiceBus.Testing offers testing by sending messages through message handlers and sagas. This includes anything that a message handler and saga can do, including header manipulation and dependency injection. You can visit http://docs.particular.net/NServiceBus/unit-testing for some basic examples. For the source code of NServiceBus.Testing, visit https://github.com/Particular/NServiceBus/tree/develop/src/NServiceBus.Testing.

The very basics of starting unit testing is to create a unit test project in Visual Studio by adding a new unit test project to an existing solution. See http://msdn.microsoft.com/en-us/library/hh598957.aspx/ for details.

We will add NServiceBus.Testing from NuGet by visiting http://www.nuget.org/packages/NServiceBus.Testing/. We will initialize the tests using Test.Initialize(), which is calling NServiceBus.Testing, thus starting the tests with either Test.Handler<HandleName>() or...