Class TestSessionContextProvider
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
currentSessionContextThe 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
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
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
contextSessionContext