Skip to main content

Definition

Assembly: CloudNimble.Breakdance.Assemblies.dll Namespace: CloudNimble.Breakdance.Assemblies Inheritance: System.Object

Syntax

CloudNimble.Breakdance.Assemblies.BreakdanceTestBase

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

public BreakdanceTestBase()

.ctor Inherited

Inherited from object

Syntax

public Object()

Properties

DefaultScope

Provides a default IServiceScope implementation to contain scoped services.

Syntax

public Microsoft.Extensions.DependencyInjection.IServiceScope DefaultScope { get; set; }

Property Value

Type: Microsoft.Extensions.DependencyInjection.IServiceScope

TestHost

The IHost instance containing the test host.

Syntax

public Microsoft.Extensions.Hosting.IHost TestHost { get; internal set; }

Property Value

Type: Microsoft.Extensions.Hosting.IHost

TestHostBuilder

The IHostBuilder instance used to configure the test host.

Syntax

public Microsoft.Extensions.Hosting.IHostBuilder TestHostBuilder { get; internal set; }

Property Value

Type: Microsoft.Extensions.Hosting.IHostBuilder

Methods

AssemblySetup Virtual

Method used by test assemblies to setup the environment.

Syntax

public virtual void AssemblySetup()

Remarks

With MSTest, use [AssemblyInitialize]. With NUnit, use [OneTimeSetup]. With xUnit, good luck: https://xunit.net/docs/shared-context

AssemblyTearDown Virtual

Method used by test assemblies to clean up the environment.

Syntax

public virtual void AssemblyTearDown()

Remarks

With MSTest, use [AssemblyCleanup]. With NUnit, use [OneTimeTearDown]. With xUnit, good luck: https://xunit.net/docs/shared-context

ClassSetup Virtual

Method used by test classes to setup the environment.

Syntax

public virtual void ClassSetup()

Remarks

With MSTest, use [ClassInitialize]. With NUnit, use [OneTimeSetup]. With xUnit, good luck: https://xunit.net/docs/shared-context

ClassTearDown Virtual

Method used by test classes to clean up the environment.

Syntax

public virtual void ClassTearDown()

Remarks

With MSTest, use [ClassCleanup]. With NUnit, use [OneTimeTearDown]. With xUnit, good luck: https://xunit.net/docs/shared-context

Dispose

Clean up disposable objects in the environment.

Syntax

public void Dispose()

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetKeyedService Virtual

Get service of type T from the System.IServiceProvider.

Syntax

public virtual T GetKeyedService<T>(string key) where T : class

Parameters

NameTypeDescription
keystringThe 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

public virtual System.Collections.Generic.IEnumerable<T> GetKeyedServices<T>(string key) where T : class

Parameters

NameTypeDescription
keystringThe

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

public T GetScopedService<T>(Microsoft.Extensions.DependencyInjection.IServiceScope scope) where T : class

Parameters

NameTypeDescription
scopeMicrosoft.Extensions.DependencyInjection.IServiceScope-

Returns

Type: T

Type Parameters

  • T -

GetScopedService

Get the requested service from the default IServiceScope provided by Breakdance.

Syntax

public T GetScopedService<T>() where T : class

Returns

Type: T

Type Parameters

  • T -

GetScopedServices

Get the requested service from the specified IServiceScope.

Syntax

public System.Collections.Generic.IEnumerable<T> GetScopedServices<T>(Microsoft.Extensions.DependencyInjection.IServiceScope scope) where T : class

Parameters

NameTypeDescription
scopeMicrosoft.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

public System.Collections.Generic.IEnumerable<T> GetScopedServices<T>() where T : class

Returns

Type: System.Collections.Generic.IEnumerable<T>

Type Parameters

  • T -

GetService Virtual

Get service of type T from the System.IServiceProvider.

Syntax

public virtual T GetService<T>() where T : class

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

public virtual System.Collections.Generic.IEnumerable<T> GetServices<T>() where T : class

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 object

Syntax

public System.Type GetType()

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

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

public void ResetTestHostBuilder()

SetClaimsPrincipalSelectorToThreadPrincipal

Sets the ClaimsPrincipalSelector to the CurrentPrincipal.

Syntax

public static void SetClaimsPrincipalSelectorToThreadPrincipal()

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

public static void SetClaimsPrincipalSelectorToThreadPrincipal(System.Collections.Generic.List<System.Security.Claims.Claim> claims, string authenticationType = "BreakdanceTests", string nameType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", string roleType = "http://schemas.microsoft.com/ws/2008/06/identity/claims/role")

Parameters

NameTypeDescription
claimsSystem.Collections.Generic.List<System.Security.Claims.Claim>The Claims to set for the test run.
authenticationTypestringIf needed, the AuthenticationType of the ClaimsIdentity. Defaults to “BreakdanceTests”.
nameTypestringThe ClaimType to specify for the Name claim. Defaults to NameIdentifier.
roleTypestringThe 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

public static void SetClaimsPrincipalSelectorToThreadPrincipal(System.Security.Claims.Claim claim, string authenticationType = "BreakdanceTests", string nameType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", string roleType = "http://schemas.microsoft.com/ws/2008/06/identity/claims/role")

Parameters

NameTypeDescription
claimSystem.Security.Claims.ClaimThe Claims to set for the test run.
authenticationTypestringIf needed, the AuthenticationType of the ClaimsIdentity. Defaults to “BreakdanceTests”.
nameTypestringThe ClaimType to specify for the Name claim. Defaults to NameIdentifier.
roleTypestringThe 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

public static void SetThreadPrincipal(System.Collections.Generic.List<System.Security.Claims.Claim> claims, string authenticationType = "BreakdanceTests", string nameType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", string roleType = "http://schemas.microsoft.com/ws/2008/06/identity/claims/role")

Parameters

NameTypeDescription
claimsSystem.Collections.Generic.List<System.Security.Claims.Claim>The Claims to set for the test run.
authenticationTypestringIf needed, the AuthenticationType of the ClaimsIdentity. Defaults to “BreakdanceTests”.
nameTypestringThe ClaimType to specify for the Name claim. Defaults to NameIdentifier.
roleTypestringThe 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

public static void SetThreadPrincipal(System.Security.Claims.Claim claim, string authenticationType = "BreakdanceTests", string nameType = "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", string roleType = "http://schemas.microsoft.com/ws/2008/06/identity/claims/role")

Parameters

NameTypeDescription
claimSystem.Security.Claims.ClaimThe Claims to set for the test run.
authenticationTypestringIf needed, the AuthenticationType of the ClaimsIdentity. Defaults to “BreakdanceTests”.
nameTypestringThe ClaimType to specify for the Name claim. Defaults to NameIdentifier.
roleTypestringThe 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

public virtual void TestSetup()

Remarks

With MSTest, use [TestInitialize]. With NUnit, use [Setup]. With xUnit, good luck: https://xunit.net/docs/shared-context

TestTearDown Virtual

Method used by test classes to clean up the environment.

Syntax

public virtual void TestTearDown()

Remarks

With MSTest, use [TestCleanup]. With NUnit, use [TearDown]. With xUnit, good luck: https://xunit.net/docs/shared-context

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?
  • System.IDisposable