Skip to main content
Table of Contents

Class TestSessionContextProvider

Namespace
Stratara.Testing
Assembly
Stratara.Testing.dll

An ISessionContextProvider test double whose Current is set directly, so code under test that reads the ambient session (repositories, encryption AAD, tenant guards) runs without HTTP middleware or a worker dispatch loop.

public sealed class TestSessionContextProvider : ISessionContextProvider
Inheritance
TestSessionContextProvider
Implements
Inherited Members
Extension Methods

Constructors

TestSessionContextProvider(SessionContext?)

Create a provider with an optional initial context.

public TestSessionContextProvider(SessionContext? current = null)

Parameters

current SessionContext

The initial session context, or null for none.

Properties

Current

The current session context, or null when none is set.

public SessionContext? Current { get; }

Property Value

SessionContext

Methods

Clear()

Clear the current session context — typically at the end of a unit of work.

public void Clear()

ForTenant(Guid, Guid?)

Create a provider preset to a ForTenant(Guid, Guid?) context.

public static TestSessionContextProvider ForTenant(Guid tenantId, Guid? userId = null)

Parameters

tenantId Guid

The Subject (data-owner) tenant id.

userId Guid?

The Subject/Actor user id, or null.

Returns

TestSessionContextProvider

A provider whose Current is owned by tenantId.

Set(SessionContext)

Set the current session context for the executing logical operation.

public void Set(SessionContext context)

Parameters

context SessionContext