HttpContextMoq 1.6.0

dotnet add package HttpContextMoq --version 1.6.0                
NuGet\Install-Package HttpContextMoq -Version 1.6.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HttpContextMoq" Version="1.6.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HttpContextMoq --version 1.6.0                
#r "nuget: HttpContextMoq, 1.6.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install HttpContextMoq as a Cake Addin
#addin nuget:?package=HttpContextMoq&version=1.6.0

// Install HttpContextMoq as a Cake Tool
#tool nuget:?package=HttpContextMoq&version=1.6.0                

HttpContextMoq

Easy mocking for ASP.NET Core HttpContext.

HttpContextMoq is an implementation of AspNetCore.Http.HttpContext that stores a Mock<HttpContext> instance and works as a proxy for the real Mock.

Instalation

Usage

Basic GET request:


var context = new HttpContextMock()
    .SetupUrl("http://localhost:8000/path")
    .SetupRequestMethod("GET");

POST request (with body):

var data = Encoding.UTF8.GetBytes("{\"Foo\":\"Bar\"");

var context = new HttpContextMock()
    .SetupUrl("http://localhost:8000/path")
    .SetupRequestMethod("POST")
    .SetupRequestContentType("application/json")
    .SetupRequestBody(new MemoryStream(data))
    .SetupRequestContentLength(data.Length);

Request/Response pair, usefull for testing Action Filters:

var data = Encoding.UTF8.GetBytes("{\"Foo\":\"Bar\"");

var context = new HttpContextMock()
    .SetupUrl("http://localhost:8000/path")
    .SetupRequestMethod("GET")
    .SetupResponseContentType("application/json")
    .SetupResponseBody(new MemoryStream(data))
    .SetupResponseContentLength(data.Length);

Development

Open the solution src\HttpContextMoq.sln on Visual Studio.

How to build the library?

Open the solution file src\HttpContextMoq.sln with Visual Studio, and Build the Solution (Build → Build Solution)

or

Execute the following make command.

make build

How to run the unit tests?

Open the solution file src\HttpContextMoq.sln with Visual Studio, and run the unit tests (Test → Run All Tests)

or

Execute the following make command.

make test

How to pack the library?

Open the solution file src\HttpContextMoq.sln with Visual Studio, and pack the HttpContextMoq (Build → Pack HttpContextMoq)

make pack

Contributing

Please read contributing for details of the code of conduct, and the process for submitting pull requests to us.

Versioning

Uses SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 is compatible.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.6.0 203,539 1/24/2024
1.5.0 562,170 3/5/2023
1.4.0 164,990 10/21/2022
1.3.0 207,551 6/28/2022
1.2.2 78,858 2/13/2022
1.2.1 62,750 8/30/2021
1.2.0 463 7/25/2021
1.1.0 387 7/20/2021
1.0.2 417 7/20/2021