# Uniform Session Testing Shows the usage of the `NServiceBus.UniformSession.Testing` package. ## Prerequisites for uniform session testing functionality The approach shown here works with the `NServiceBus.UniformSession` NuGet package version 2.2.0 or above. Install the `NServiceBus.UniformSession.Testing` NuGet package. ### Testing services Construct the service under test with an instance of `TestableUniformSession`. Call the methods being tested and make assertions about the messages sent and published. ```cs var session = new TestableUniformSession(); var service = new SomeService(session); service.DoTheThing(); Assert.AreEqual(1, session.SentMessages.Length); ``` ### Testing a handler Construct the handler under test with an instance of `TestableUniformSession`. ```cs var session = new TestableUniformSession(); var sharedComponent = new SharedComponent(session); var handler = new SomeMessageHandler(sharedComponent); Test.Handler(handler) .WithUniformSession(session) .ExpectPublish() .OnMessage(); ``` ### Testing a saga Construct the saga under test with an instance of `TestableUniformSession`. ```cs var session = new TestableUniformSession(); var saga = new SomeSaga(session); Test.Saga(saga) .WithUniformSession(session) .ExpectPublish() .WhenHandling(); ```