Definition
Assembly: CloudNimble.Breakdance.Assemblies.dll Namespace: CloudNimble.Breakdance.Assemblies Inheritance: System.ObjectSyntax
Summary
A base class for unit tests that maintains an IHost with configuration and a Dependency Injection container.Constructors
.ctor
Creates a new BreakdanceTestBase instance.Syntax
.ctor Inherited
Inherited from
objectSyntax
Properties
DefaultScope
Provides a default IServiceScope implementation to contain scoped services.Syntax
Property Value
Type:Microsoft.Extensions.DependencyInjection.IServiceScope
TestHost
The IHost instance containing the test host.Syntax
Property Value
Type:Microsoft.Extensions.Hosting.IHost
TestHostBuilder
The IHostBuilder instance used to configure the test host.Syntax
Property Value
Type:Microsoft.Extensions.Hosting.IHostBuilder
Methods
AssemblySetup Virtual
Method used by test assemblies to setup the environment.Syntax
Remarks
With MSTest, use [AssemblyInitialize]. With NUnit, use [OneTimeSetup]. With xUnit, good luck: https://xunit.net/docs/shared-contextAssemblyTearDown Virtual
Method used by test assemblies to clean up the environment.Syntax
Remarks
With MSTest, use [AssemblyCleanup]. With NUnit, use [OneTimeTearDown]. With xUnit, good luck: https://xunit.net/docs/shared-contextClassSetup Virtual
Method used by test classes to setup the environment.Syntax
Remarks
With MSTest, use [ClassInitialize]. With NUnit, use [OneTimeSetup]. With xUnit, good luck: https://xunit.net/docs/shared-contextClassTearDown Virtual
Method used by test classes to clean up the environment.Syntax
Remarks
With MSTest, use [ClassCleanup]. With NUnit, use [OneTimeTearDown]. With xUnit, good luck: https://xunit.net/docs/shared-contextDispose
Clean up disposable objects in the environment.Syntax
Equals Inherited Virtual
Inherited from
objectSyntax
Parameters
| Name | Type | Description |
|---|---|---|
obj | object? | - |
Returns
Type:bool
Equals Inherited
Inherited from
objectSyntax
Parameters
| Name | Type | Description |
|---|---|---|
objA | object? | - |
objB | object? | - |
Returns
Type:bool
GetHashCode Inherited Virtual
Inherited from
objectSyntax
Returns
Type:int
GetKeyedService Virtual
Get service of type T from the System.IServiceProvider.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
key | string | The key of the service to get. |
Returns
Type:T
A service object of type T.
Type Parameters
T- The type of service object to get.
GetKeyedServices Virtual
Get services of type T from the System.IServiceProvider.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
key | string | The |
Returns
Type:System.Collections.Generic.IEnumerable<T>
An IEnumerable`1 of type T.
Type Parameters
T- The type of service object to get.
GetScopedService
Get the requested service from the specified IServiceScope.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
scope | Microsoft.Extensions.DependencyInjection.IServiceScope | - |
Returns
Type:T
Type Parameters
T-
GetScopedService
Get the requested service from the default IServiceScope provided by Breakdance.Syntax
Returns
Type:T
Type Parameters
T-
GetScopedServices
Get the requested service from the specified IServiceScope.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
scope | Microsoft.Extensions.DependencyInjection.IServiceScope | - |
Returns
Type:System.Collections.Generic.IEnumerable<T>
Type Parameters
T-
GetScopedServices
Get the requested service from the default IServiceScope provided by Breakdance.Syntax
Returns
Type:System.Collections.Generic.IEnumerable<T>
Type Parameters
T-
GetService Virtual
Get service of type T from the System.IServiceProvider.Syntax
Returns
Type:T
A service object of type T.
Type Parameters
T- The type of service object to get.
GetServices Virtual
Get an enumeration of services of type T from the System.IServiceProvider.Syntax
Returns
Type:System.Collections.Generic.IEnumerable<T>
An enumeration of services of type T.
Type Parameters
T- The type of service object to get.
GetType Inherited
Inherited from
objectSyntax
Returns
Type:System.Type
MemberwiseClone Inherited
Inherited from
objectSyntax
Returns
Type:object
ReferenceEquals Inherited
Inherited from
objectSyntax
Parameters
| Name | Type | Description |
|---|---|---|
objA | object? | - |
objB | object? | - |
Returns
Type:bool
ResetTestHostBuilder
Resets the test host by disposing of the current TestHost and initializing a new default TestHostBuilder. This prepares the environment for a fresh test setup.Syntax
SetClaimsPrincipalSelectorToThreadPrincipal
Sets the ClaimsPrincipalSelector to the CurrentPrincipal.Syntax
Remarks
This is used in non-ASP.NET Core testing situations where you’re not going to pull the Identity from a request-specific DI Container.SetClaimsPrincipalSelectorToThreadPrincipal
Sets the ClaimsPrincipalSelector to the CurrentPrincipal and sets the latter to a new ClaimsIdentity with the specified claims.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
claims | System.Collections.Generic.List<System.Security.Claims.Claim> | The Claims to set for the test run. |
authenticationType | string | If needed, the AuthenticationType of the ClaimsIdentity. Defaults to “BreakdanceTests”. |
nameType | string | The ClaimType to specify for the Name claim. Defaults to NameIdentifier. |
roleType | string | The ClaimType to specify for Role claims. Defaults to Role. |
Remarks
This is used in non-ASP.NET Core testing situations where you’re not going to pull the Identity from a request-specific DI Container.SetClaimsPrincipalSelectorToThreadPrincipal
Sets the ClaimsPrincipalSelector to the CurrentPrincipal and sets the latter to a new ClaimsIdentity with the specified claim.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
claim | System.Security.Claims.Claim | The Claims to set for the test run. |
authenticationType | string | If needed, the AuthenticationType of the ClaimsIdentity. Defaults to “BreakdanceTests”. |
nameType | string | The ClaimType to specify for the Name claim. Defaults to NameIdentifier. |
roleType | string | The ClaimType to specify for Role claims. Defaults to Role. |
Remarks
This is used in non-ASP.NET Core testing situations where you’re not going to pull the Identity from a request-specific DI Container.SetThreadPrincipal
Sets the ClaimsPrincipalSelector to a new ClaimsIdentity with the specified claims.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
claims | System.Collections.Generic.List<System.Security.Claims.Claim> | The Claims to set for the test run. |
authenticationType | string | If needed, the AuthenticationType of the ClaimsIdentity. Defaults to “BreakdanceTests”. |
nameType | string | The ClaimType to specify for the Name claim. Defaults to NameIdentifier. |
roleType | string | The ClaimType to specify for Role claims. Defaults to Role. |
Remarks
This is used in non-ASP.NET Core testing situations where you’re not going to pull the Identity from a request-specific DI Container.SetThreadPrincipal
Sets the ClaimsPrincipalSelector to a new ClaimsIdentity with the specified claim.Syntax
Parameters
| Name | Type | Description |
|---|---|---|
claim | System.Security.Claims.Claim | The Claims to set for the test run. |
authenticationType | string | If needed, the AuthenticationType of the ClaimsIdentity. Defaults to “BreakdanceTests”. |
nameType | string | The ClaimType to specify for the Name claim. Defaults to NameIdentifier. |
roleType | string | The ClaimType to specify for Role claims. Defaults to Role. |
Remarks
This is used in non-ASP.NET Core testing situations where you’re not going to pull the Identity from a request-specific DI Container.TestSetup Virtual
Method used by test classes to setup the environment.Syntax
Remarks
With MSTest, use [TestInitialize]. With NUnit, use [Setup]. With xUnit, good luck: https://xunit.net/docs/shared-contextTestTearDown Virtual
Method used by test classes to clean up the environment.Syntax
Remarks
With MSTest, use [TestCleanup]. With NUnit, use [TearDown]. With xUnit, good luck: https://xunit.net/docs/shared-contextToString Inherited Virtual
Inherited from
objectSyntax
Returns
Type:string?
Related APIs
- System.IDisposable