Table of Contents

AddFakeHttpContextAccessor Method

Definition

Namespace
Codebelt.Extensions.Xunit.Hosting.AspNetCore
Assemblies
Codebelt.Extensions.Xunit.Hosting.AspNetCore.dll
Source
src/Codebelt.Extensions.Xunit.Hosting.AspNetCore/ServiceCollectionExtensions.cs

AddFakeHttpContextAccessor(IServiceCollection, ServiceLifetime)

Adds a unit test optimized implementation for the IHttpContextAccessor service.

public static IServiceCollection AddFakeHttpContextAccessor(this IServiceCollection services, ServiceLifetime lifetime = ServiceLifetime.Singleton)

Parameters

services IServiceCollection

The IServiceCollection to extend.

lifetime ServiceLifetime

The lifetime of the service. Default is Singleton.

Returns

IServiceCollection

A reference to services after the operation has completed.