Semantica.Lib.TestTools.SimpleInjector 8.1.0

dotnet add package Semantica.Lib.TestTools.SimpleInjector --version 8.1.0
                    
NuGet\Install-Package Semantica.Lib.TestTools.SimpleInjector -Version 8.1.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="Semantica.Lib.TestTools.SimpleInjector" Version="8.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Semantica.Lib.TestTools.SimpleInjector" Version="8.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Semantica.Lib.TestTools.SimpleInjector" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Semantica.Lib.TestTools.SimpleInjector --version 8.1.0
                    
#r "nuget: Semantica.Lib.TestTools.SimpleInjector, 8.1.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.
#:package Semantica.Lib.TestTools.SimpleInjector@8.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Semantica.Lib.TestTools.SimpleInjector&version=8.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Semantica.Lib.TestTools.SimpleInjector&version=8.1.0
                    
Install as a Cake Tool

Semantica.Lib.TestTools.SimpleInjector

This package is part of the testing packages of Semantica.Lib.

Summary

Provides two abstract base classes in order make compact unit tests that verify registrations of your DI modules based on Semantica.Lib.Core.DependencyInjection.ModuleBase. Use ContainerModuleTestBase to make unit tests when you use SimpleInjector.Container as your DI container, or ServiceCollectionModuleTestBase to make unit tests when you use System.Extensions.DependencyInjection.IServiceCollection as you DI container.

Both implementations leverage SimpleInjector's Container.Verify() method for registration validation.

Contents

The outline base class (from Semantica.Lib.TestTools.Core) provides three methods that should be called from your test assembly.

[TestClass]
public class MyModuleTest : ContainerModuleTestBase<MyModule>
{
    [TestMethod]
    public override void Register_Verify_DoesNotThrow()
    {
        Initialize(); //sets up the DI container
        Act(); //calls the registration method of MyModule
        Assert(); //verifies registration, and throws when a missing registration is encountered
    }
}

This example tests the MyModule registrations, and all dependent modules. In this case using MSTest, and a SimpleInjector container.

When the module is dependent on reverse dependencies (interfaces that have their implementations registered upstream of the module), these registrations have to registered by overriding RegisterInvertedDependencies and calling RegisterAsMock for each reversed dependency.

    protected override void RegisterInvertedDependencies()
    {
        RegisterAsMock<IMyReverseDependency>();
    }

Dependencies

  • Moq
  • MSTest.TestFramework
  • Semantica.Lib.Checks
  • Semantica.Lib.Core
  • Semantica.Lib.Core.SimpleInjector
  • Semantica.Lib.Intervals
  • Semantica.Lib.Patterns
  • Semantica.Lib.TestTools.Core
  • Semantica.Lib.Types
  • SimpleInjector

Documentation generated from the XMLDoc:

<a name='assembly'></a>

Lib.TestTools.SimpleInjector

Contents

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  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 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.1.0 107 5/30/2025
8.0.7 145 9/6/2024
8.0.6-beta 121 7/10/2024
8.0.5-beta 118 7/4/2024
8.0.4-beta 110 7/2/2024
8.0.3-beta 113 6/14/2024
8.0.2-beta 104 6/4/2024
8.0.1-beta 105 6/4/2024
8.0.0-beta 103 6/4/2024
6.6.1-beta 120 4/5/2024
6.6.0-beta 130 3/5/2024
6.5.5-alpha2 106 3/4/2024
6.5.4-beta 113 2/29/2024
6.5.3-beta 164 10/5/2023
6.5.2-beta 130 10/5/2023
6.5.1-beta 149 9/29/2023
6.5.0-beta 137 9/22/2023
6.4.0-beta 173 7/11/2023
6.3.0-beta 167 6/15/2023
6.2.5-beta 247 3/14/2023
6.2.4-beta 625 10/12/2022
6.2.3-beta 304 9/1/2022
6.2.1-beta 216 8/25/2022