Skip to content

How integrate support class with your class

NightAngell edited this page Feb 24, 2019 · 10 revisions

After you add nuget to your test project, SignalR_UnitTestingSupport is ready to use.

All IHubContext support classes are in SignalR_UnitTestingSupportCommon.IHubContextSupport namespace

For NUnit: All testing base classes are in SignalR_UnitTestingSupport.Hubs namespace

For xUnit: All testing base classes are in SignalR_UnitTestingSupportXUnit.Hubs namespace

For MSTest: All testing base classes are in SignalR_UnitTestingSupportMSTest.Hubs namespace

1) Base classes approach (Recommended)

Create test class for hub for example:

class ExampleHubTests {}

And then:

1. For testing Hub

class ExampleHubTests : HubUnitTestsBase {}

2. For testing Hub<T>

class ExampleHubTests : HubUnitTestsBase<T> {}

3. For testing Hub with EntityFrameworkCore

class ExampleHubTests : HubUnitTestsWithEF<TDbContext> {}

TDbContext is any class which inherit from Microsoft.EntityFrameworkCore.DbContext or DbContext itself.

4. For testing Hub<T> with EntityFrameworkCore

class ExampleHubTests : HubUnitTestsWithEF<T, TDbContext> {}

TDbContext is any class which inherit from Microsoft.EntityFrameworkCore.DbContext or DbContext itself.

5. For testing with IHubContext<THub> see this.

5. For testing with IHubContext<THub, TIHubResponses> see this.

2) Testing objects approach (Alternative, if you can't use base classes).

How use second approach. See this.

Clone this wiki locally