SignalR.UnitTestingSupport.MSTest 7.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SignalR.UnitTestingSupport.MSTest --version 7.0.0                
NuGet\Install-Package SignalR.UnitTestingSupport.MSTest -Version 7.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SignalR.UnitTestingSupport.MSTest" Version="7.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SignalR.UnitTestingSupport.MSTest --version 7.0.0                
#r "nuget: SignalR.UnitTestingSupport.MSTest, 7.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SignalR.UnitTestingSupport.MSTest as a Cake Addin
#addin nuget:?package=SignalR.UnitTestingSupport.MSTest&version=7.0.0

// Install SignalR.UnitTestingSupport.MSTest as a Cake Tool
#tool nuget:?package=SignalR.UnitTestingSupport.MSTest&version=7.0.0                

For the latest versions of NUnit version see: https://www.nuget.org/packages/SignalR.UnitTestingSupport.NUnit/

For the latest versions of xUnit version see: https://www.nuget.org/packages/SignalR.UnitTestingSupport.xUnit

For the latest versions of MSTest version see: https://www.nuget.org/packages/SignalR.UnitTestingSupport.MSTest/

For full docs see: https://github.com/NightAngell/SignalR_UnitTestingSupport/wiki

What it is?

This lib provide support objects and base classes for testing Hub, Hub<T>, IHubContext<T>, IHubContext<T, P>. For example preconfigured mocks and helpfull verify methods. There is also support for testing Hubs and IHubContexts with Entity Framework Core.

Which nuget version should I choose?

  1. netcoreapp (2.1, 2,2, 3.0, 3,1) - 2.0.0
  2. net5 - 5.0.0
  3. net6.0 - 6.0.0
  4. net7.0 - 7.0.0

How to install

1. Using Visual Studio Nuget Package Manager

If you dont know how install nuget via Visual Studio see this: https://www.youtube.com/watch?v=jX5HlrerIos

SignalR.UnitTestingSupport.NUnit
SignalR.UnitTestingSupport.xUnit
SignalR.UnitTestingSupport.MSTest
2. Using Packet Manager Console
Install-Package SignalR.UnitTestingSupport.NUnit -Version 7.0.0
Install-Package SignalR.UnitTestingSupport.xUnit -Version 7.0.0
Install-Package SignalR.UnitTestingSupport.MSTest -Version 7.0.0
3. Using .Net CLI
dotnet add package SignalR.UnitTestingSupport.NUnit --version 7.0.0
dotnet add package SignalR.UnitTestingSupport.xUnit --version 7.0.0
dotnet add package SignalR.UnitTestingSupport.MSTest --version 7.0.0

Troubleshooting!

Install NUnit3TestAdapter nuget for visual studio testing with NUnit in visual studio. https://www.nuget.org/packages/NUnit3TestAdapter/

Install xunit.runner.visualstudio nuget for visual studio testing with xUnit. https://www.nuget.org/packages/xunit.runner.visualstudio/

Install MSTest.TestAdapter nuget for visual studio testing with MSTest.
https://www.nuget.org/packages/MSTest.TestAdapter/

If your tests are not even detected, install Microsoft.Net.Test.Sdk nuget 😃
https://www.nuget.org/packages/Microsoft.NET.Test.Sdk/

If you get NullReferenceException when you try testing with my lib see this.

Error after update for ASP.NET Core 3.0: Help with migration from ASP.NET Core 2.1 or 2.2 to 3.0

Help with migration from netstandard2.0 to netstandard.2.1 compatibile project

How to use

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

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.

For full docs see: Docs

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.0 5,816 12/29/2023
7.0.0 4,999 11/26/2022
6.0.0 4,383 3/13/2022
5.0.0 14,255 4/3/2021
2.0.0 2,763 8/21/2019
1.1.0 655 2/23/2019
1.0.0 681 2/17/2019

Updated to net7.0. Updated dependencies.