HttpContextMoq 1.6.0
dotnet add package HttpContextMoq --version 1.6.0
NuGet\Install-Package HttpContextMoq -Version 1.6.0
<PackageReference Include="HttpContextMoq" Version="1.6.0" />
paket add HttpContextMoq --version 1.6.0
#r "nuget: HttpContextMoq, 1.6.0"
// 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
- Tiago Araújo - Initial work - tiagodaraujo
See also the list of contributors who participated in this project.
Product | Versions 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. |
-
.NETCoreApp 3.0
- Moq (>= 4.16.1)
-
.NETCoreApp 3.1
- Moq (>= 4.16.1)
-
.NETStandard 2.0
- Microsoft.AspNetCore.Http.Extensions (>= 2.2.0)
- Microsoft.AspNetCore.Http.Features (>= 2.2.0)
- Microsoft.AspNetCore.WebUtilities (>= 2.2.0)
- Moq (>= 4.16.1)
-
.NETStandard 2.1
- Microsoft.AspNetCore.Http.Extensions (>= 2.2.0)
- Microsoft.AspNetCore.Http.Features (>= 2.2.0)
- Microsoft.AspNetCore.WebUtilities (>= 2.2.0)
- Moq (>= 4.16.1)
-
net5.0
- Moq (>= 4.16.1)
-
net6.0
- Moq (>= 4.16.1)
-
net7.0
- Moq (>= 4.16.1)
-
net8.0
- Moq (>= 4.16.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.