Semantica.Lib.TestTools.Core
8.1.0
dotnet add package Semantica.Lib.TestTools.Core --version 8.1.0
NuGet\Install-Package Semantica.Lib.TestTools.Core -Version 8.1.0
<PackageReference Include="Semantica.Lib.TestTools.Core" Version="8.1.0" />
<PackageVersion Include="Semantica.Lib.TestTools.Core" Version="8.1.0" />
<PackageReference Include="Semantica.Lib.TestTools.Core" />
paket add Semantica.Lib.TestTools.Core --version 8.1.0
#r "nuget: Semantica.Lib.TestTools.Core, 8.1.0"
#:package Semantica.Lib.TestTools.Core@8.1.0
#addin nuget:?package=Semantica.Lib.TestTools.Core&version=8.1.0
#tool nuget:?package=Semantica.Lib.TestTools.Core&version=8.1.0
Semantica.Lib.TestTools.Core
This package is part of the testing packages of Semantica.Lib.
Summary
Provides a set of specific MSTest.Assert extensions (Assert.That.
), to facilitate more compact assertions, and more
comprehensive fail messages. Assertions include epsilon-checking for floating point types, default/empty checking for enums,
strings, ICanBeEmpty
, etc., DateOnly/DateTime part assertions, as well as assertions for the Semantica.Lib.Checks.Chk
type.
Also contains a convenient mock for Semantica.Lib.Core.Providers.IDateTimeProvider
, and ModuleTestBase
, an abstract base
class to facilitate making unit tests for DI modules based on Semantica.Lib.Core.DependencyInjection.ModuleBase
.
Contents
ModuleTestBase
This abstract base class is just a framework to make a generic unittest base class. Two expansions of this base class have been
provided in Semantica.Lib.TestTools.SimpleInjector that leverage SimpleInjector to verify registrations that are done with
either SimpleInjector.Container
or System.Extensions.DependencyInjection.IServiceCollection
(or a mix of both). When
using a different DI container, it could be helpful to base your unit test base class on that code.
Dependencies
- Moq
- MSTest.TestFramework
- Semantica.Lib.Checks
- Semantica.Lib.Core
- Semantica.Lib.Extensions
- Semantica.Lib.Patterns
- Semantica.Lib.Types
Documentation generated from the XMLDoc:
<a name='assembly'></a>
Lib.TestTools.Core
Contents
<a name='T-Semantica-TestTools-Core-Assertions-ChkAssertExtensions'></a>
ChkAssertExtensions type
Namespace
Semantica.TestTools.Core.Assertions
<a name='M-Semantica-TestTools-Core-Assertions-ChkAssertExtensions-HasFailed-Microsoft-VisualStudio-TestTools-UnitTesting-Assert,Semantica-Checks-IChk,System-String-'></a>
HasFailed() method
Summary
Asserts if the chk
is a determined Fail.
Parameters
This method has no parameters.
<a name='M-Semantica-TestTools-Core-Assertions-ChkAssertExtensions-HasPassed-Microsoft-VisualStudio-TestTools-UnitTesting-Assert,Semantica-Checks-IChk,System-String-'></a>
HasPassed() method
Summary
Asserts if the chk
is a determined Pass.
Parameters
This method has no parameters.
<a name='M-Semantica-TestTools-Core-Assertions-ChkAssertExtensions-HasPayload1-Microsoft-VisualStudio-TestTools-UnitTesting-Assert,Semantica-Checks-Chk{
0},System-String-'></a>
HasPayload``1() method
Summary
Asserts if the chk
contains a non-default payload.
Parameters
This method has no parameters.
<a name='M-Semantica-TestTools-Core-Assertions-ChkAssertExtensions-HasReason-Microsoft-VisualStudio-TestTools-UnitTesting-Assert,Semantica-Checks-IChk,System-String-'></a>
HasReason() method
Summary
Asserts if the chk
contains a reason.
Parameters
This method has no parameters.
<a name='M-Semantica-TestTools-Core-Assertions-ChkAssertExtensions-IsDetermined-Microsoft-VisualStudio-TestTools-UnitTesting-Assert,Semantica-Checks-IChk,System-String-'></a>
IsDetermined() method
Summary
Asserts if the chk
is determined.
Parameters
This method has no parameters.
<a name='M-Semantica-TestTools-Core-Assertions-ChkAssertExtensions-IsFail-Microsoft-VisualStudio-TestTools-UnitTesting-Assert,Semantica-Checks-IChk,System-String-'></a>
IsFail() method
Summary
Asserts if the chk
is a Fail.
Parameters
This method has no parameters.
Remarks
Caution! Does not check if the chk is determined. Always use Assert.HasFailed unless you specifically do not want the IsDetermined assert.
<a name='M-Semantica-TestTools-Core-Assertions-ChkAssertExtensions-IsFailPayload1-Microsoft-VisualStudio-TestTools-UnitTesting-Assert,Semantica-Checks-Chk{
0},System-String-'></a>
IsFailPayload``1() method
Summary
Asserts if the chk
is an undetermined Fail with a payload.
Parameters
This method has no parameters.
<a name='M-Semantica-TestTools-Core-Assertions-ChkAssertExtensions-IsFailReason-Microsoft-VisualStudio-TestTools-UnitTesting-Assert,Semantica-Checks-IChk,System-String-'></a>
IsFailReason() method
Summary
Asserts if the chk
is an undetermined Fail with a reason.
Parameters
This method has no parameters.
<a name='M-Semantica-TestTools-Core-Assertions-ChkAssertExtensions-IsPass-Microsoft-VisualStudio-TestTools-UnitTesting-Assert,Semantica-Checks-IChk,System-String-'></a>
IsPass() method
Summary
Asserts if the chk
is a Pass.
Parameters
This method has no parameters.
Remarks
Caution! Does not check if the chk is determined. Always use Assert.HasFailed unless you specifically do not want the IsDetermined assert.
<a name='M-Semantica-TestTools-Core-Assertions-ChkAssertExtensions-IsPassPayload1-Microsoft-VisualStudio-TestTools-UnitTesting-Assert,Semantica-Checks-Chk{
0},System-String-'></a>
IsPassPayload``1() method
Summary
Asserts if the chk
is an undetermined Pass with a payload.
Parameters
This method has no parameters.
<a name='M-Semantica-TestTools-Core-Assertions-ChkAssertExtensions-IsPassReason-Microsoft-VisualStudio-TestTools-UnitTesting-Assert,Semantica-Checks-IChk,System-String-'></a>
IsPassReason() method
Summary
Asserts if the chk
is an undetermined Pass with a reason.
Parameters
This method has no parameters.
<a name='M-Semantica-TestTools-Core-Assertions-ChkAssertExtensions-IsUndetermined-Microsoft-VisualStudio-TestTools-UnitTesting-Assert,Semantica-Checks-IChk,System-String-'></a>
IsUndetermined() method
Summary
Asserts if the chk
is undetermined.
Parameters
This method has no parameters.
<a name='T-Semantica-TestTools-Core-ModuleTestBase`1'></a>
ModuleTestBase`1 type
Namespace
Semantica.TestTools.Core
<a name='F-Semantica-TestTools-Core-ModuleTestBase`1-Sut'></a>
Sut constants
Summary
System under test. Has to be assigned during construction or initialization of the test class.
<a name='M-Semantica-TestTools-Core-ModuleTestBase`1-Act-System-Boolean-'></a>
Act() method
Summary
Performs the Act part of the generic test. Call from Register_Verify_DoesNotThrow.
Parameters
This method has no parameters.
<a name='M-Semantica-TestTools-Core-ModuleTestBase`1-Assert'></a>
Assert() method
Summary
Performs the Assert parts of the generic test. Call from Register_Verify_DoesNotThrow.
Parameters
This method has no parameters.
<a name='M-Semantica-TestTools-Core-ModuleTestBase`1-Initialize'></a>
Initialize() method
Summary
Initializes the test. Call before Act;
Parameters
This method has no parameters.
<a name='M-Semantica-TestTools-Core-ModuleTestBase`1-RegisterAsMock``1'></a>
RegisterAsMock``1() method
Summary
Registers a generic mock to represent a dependency that is always implemented in an upstream module.
Parameters
This method has no parameters.
Generic Types
Name | Description |
---|---|
TDependency | Type to register a generic mock for. |
Remarks
Use in the override of the RegisterInvertedDependencies method.
<a name='M-Semantica-TestTools-Core-ModuleTestBase`1-RegisterInvertedDependencies'></a>
RegisterInvertedDependencies() method
Summary
Override this method to registers all dependencies that are always implemented in a module that is upstream from the context of this module. Note that any implementations registered here always have to be registered, otherwise the runtime (verification) will fail. The registrations added here effectively create unavoidable "blind spots" for the unit test verification.
Parameters
This method has no parameters.
<a name='M-Semantica-TestTools-Core-ModuleTestBase`1-Register_Verify_DoesNotThrow'></a>
Register_Verify_DoesNotThrow() method
Summary
Test method to be called by the unittesting framework.
Parameters
This method has no parameters.
Remarks
Should call Act and Assert for the test to work.
<a name='T-Semantica-TestTools-Core-Mocks-TestDateTimeProvider'></a>
TestDateTimeProvider type
Namespace
Semantica.TestTools.Core.Mocks
Summary
Provides an implementation of IDateTimeProvider that can be set fixed to a specific time. Can be used as a mock in other tests.
<a name='M-Semantica-TestTools-Core-Mocks-TestDateTimeProvider-#ctor-System-DateTime-'></a>
#ctor(utcNow) constructor
Summary
Initializes UtcNow with the provided value, and a fixed timezone "W. Europe Standard Time".
Parameters
Name | Type | Description |
---|---|---|
utcNow | System.DateTime | The fixed value for UtcNow. |
<a name='M-Semantica-TestTools-Core-Mocks-TestDateTimeProvider-#ctor-System-DateTime,System-String-'></a>
#ctor(utcNow,timezoneId) constructor
Summary
Initializes UtcNow with the provided value, and a timezone identified by timezoneId
.
Parameters
Name | Type | Description |
---|---|---|
utcNow | System.DateTime | The fixed value for UtcNow. |
timezoneId | System.String | The id (an OS-specific identifier string) of the time zone to be used. |
<a name='M-Semantica-TestTools-Core-Mocks-TestDateTimeProvider-#ctor-System-DateTime,System-TimeSpan-'></a>
#ctor(utcNow,fixedOffset) constructor
Summary
Initializes UtcNow with the provided value, and a fixed timezone offset (no DST).
Parameters
Name | Type | Description |
---|---|---|
utcNow | System.DateTime | The fixed value for UtcNow. |
fixedOffset | System.TimeSpan | The fixed value for Offset. |
<a name='M-Semantica-TestTools-Core-Mocks-TestDateTimeProvider-#ctor-System-DateTime,System-TimeZoneInfo-'></a>
#ctor(utcNow,timezone) constructor
Summary
Initializes UtcNow with the provided value, and a provided timezone.
Parameters
Name | Type | Description |
---|---|---|
utcNow | System.DateTime | The fixed value for UtcNow. |
timezone | System.TimeZoneInfo | An instance of TimeZoneInfo to be used. |
<a name='M-Semantica-TestTools-Core-Mocks-TestDateTimeProvider-SetUtcNow-System-DateTime-'></a>
SetUtcNow(dateTime) method
Summary
Not part of IDateTimeProvider interface implementation. Can set Now after construction.
Parameters
Name | Type | Description |
---|---|---|
dateTime | System.DateTime | The new value of UtcNow |
Product | Versions 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. |
-
net6.0
- Moq (>= 4.20.69)
- MSTest.TestFramework (>= 3.4.0)
- Semantica.Lib.Checks (>= 8.1.0)
- Semantica.Lib.Core (>= 8.1.0)
- Semantica.Lib.Extensions (>= 8.1.0)
- Semantica.Lib.Intervals (>= 8.1.0-beta)
- Semantica.Lib.Patterns (>= 8.1.0)
- Semantica.Lib.Types (>= 8.1.0)
-
net7.0
- Moq (>= 4.20.69)
- MSTest.TestFramework (>= 3.4.0)
- Semantica.Lib.Checks (>= 8.1.0)
- Semantica.Lib.Core (>= 8.1.0)
- Semantica.Lib.Extensions (>= 8.1.0)
- Semantica.Lib.Intervals (>= 8.1.0-beta)
- Semantica.Lib.Patterns (>= 8.1.0)
- Semantica.Lib.Types (>= 8.1.0)
-
net8.0
- Moq (>= 4.20.69)
- MSTest.TestFramework (>= 3.4.0)
- Semantica.Lib.Checks (>= 8.1.0)
- Semantica.Lib.Core (>= 8.1.0)
- Semantica.Lib.Extensions (>= 8.1.0)
- Semantica.Lib.Intervals (>= 8.1.0-beta)
- Semantica.Lib.Patterns (>= 8.1.0)
- Semantica.Lib.Types (>= 8.1.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Semantica.Lib.TestTools.Core:
Package | Downloads |
---|---|
Semantica.Lib.TestTools.SimpleInjector
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. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
8.1.0 | 120 | 5/30/2025 |
8.0.7 | 171 | 9/6/2024 |
8.0.6-beta | 131 | 7/10/2024 |
8.0.5-beta | 132 | 7/4/2024 |
8.0.4-beta | 125 | 7/2/2024 |
8.0.3-beta | 133 | 6/14/2024 |
8.0.2-beta | 132 | 6/4/2024 |
8.0.1-beta | 121 | 6/4/2024 |
8.0.0-beta | 123 | 6/4/2024 |
6.6.1-beta | 139 | 4/5/2024 |
6.6.0-beta | 146 | 3/5/2024 |
6.5.5-alpha2 | 115 | 3/4/2024 |
6.5.4-beta | 135 | 2/29/2024 |
6.5.3-beta | 173 | 10/5/2023 |
6.5.2-beta | 153 | 10/5/2023 |
6.5.1-beta | 164 | 9/29/2023 |
6.5.0-beta | 149 | 9/22/2023 |
6.4.0-beta | 190 | 7/11/2023 |
6.3.0-beta | 187 | 6/15/2023 |
6.2.5-beta | 254 | 3/14/2023 |
6.2.4-beta | 627 | 10/12/2022 |
6.2.3-beta | 304 | 9/1/2022 |
6.2.1-beta | 215 | 8/25/2022 |