GraphQL.AspNet.TestFramework
2.0.0-beta1
This is a prerelease version of GraphQL.AspNet.TestFramework.
dotnet add package GraphQL.AspNet.TestFramework --version 2.0.0-beta1
NuGet\Install-Package GraphQL.AspNet.TestFramework -Version 2.0.0-beta1
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="GraphQL.AspNet.TestFramework" Version="2.0.0-beta1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GraphQL.AspNet.TestFramework" Version="2.0.0-beta1" />
<PackageReference Include="GraphQL.AspNet.TestFramework" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GraphQL.AspNet.TestFramework --version 2.0.0-beta1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: GraphQL.AspNet.TestFramework, 2.0.0-beta1"
#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.
#addin nuget:?package=GraphQL.AspNet.TestFramework&version=2.0.0-beta1&prerelease
#tool nuget:?package=GraphQL.AspNet.TestFramework&version=2.0.0-beta1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
GraphQL ASP.NET Test Framework
General Documentation
Test Framework Documentation
GraphQL ASP.NET is a fully featured graphql library that utilizes a controller/action programming model similar to ASP.NET. This library is a 1st party test framework to allow you quickly spin up a test server and test your controller methods in an isolated manner.
// Excute a simple Test against a controller method
public async Task WhenGivenTwoNumbers_TheSumIsReturned()
{
// **Arrange**
var expectedOutput = @"{
""data"" : {
""addTwoNumbers"": 13
}
}"
// generate a 'server' of a schema with one controller
var server = new TestServerBuilder()
.AddController<CalculatorController>()
.Build();
// build a request to send to the server
var queryBuilder = server.CreateQueryContextBuilder();
queryBuilder.AddQueryText("query { addTwoNumbers(num1: 5, num2: 8) }");
// **Act**
var jsonResult = await server.RenderResult(queryBuilder);
// **Assert**
CommonAssertions.AreEqualJsonStrings(expectedOutput, jsonResult);
}
Supported Features
- Setup specific authentication and authorization scenarios to test security.
- Mock and inject any dependencies for your controllers.
- Interrogate the
IQueryExecutionResult
object for specific data, messages, metrics or thrown exceptions. - Render the resultant json document that would be sent to the requestor.
Read the documentation for full details
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- GraphQL.AspNet (>= 2.0.0-beta1)
- NSubstitute (>= 5.0.0)
- System.Collections.Immutable (>= 1.6.0)
- System.ComponentModel.Annotations (>= 4.3.0)
- System.Drawing.Common (>= 4.7.2)
- System.Runtime.Caching (>= 4.6.0)
- System.Text.Encodings.Web (>= 4.7.2)
- System.Text.Json (>= 4.6.0)
- System.Text.RegularExpressions (>= 4.3.1)
-
net7.0
- GraphQL.AspNet (>= 2.0.0-beta1)
- NSubstitute (>= 5.0.0)
- System.Collections.Immutable (>= 1.6.0)
- System.ComponentModel.Annotations (>= 4.3.0)
- System.Drawing.Common (>= 4.7.2)
- System.Runtime.Caching (>= 4.6.0)
- System.Text.Encodings.Web (>= 4.7.2)
- System.Text.Json (>= 4.6.0)
- System.Text.RegularExpressions (>= 4.3.1)
-
net8.0
- GraphQL.AspNet (>= 2.0.0-beta1)
- NSubstitute (>= 5.0.0)
- System.Collections.Immutable (>= 1.6.0)
- System.ComponentModel.Annotations (>= 4.3.0)
- System.Drawing.Common (>= 4.7.2)
- System.Runtime.Caching (>= 4.6.0)
- System.Text.Encodings.Web (>= 4.7.2)
- System.Text.Json (>= 4.6.0)
- System.Text.RegularExpressions (>= 4.3.1)
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 |
---|---|---|
2.0.0-beta1 | 453 | 11/26/2023 |
1.4.3 | 119 | 4/25/2025 |
1.4.2 | 6,024 | 10/21/2024 |
1.4.1 | 4,105 | 7/9/2024 |
1.4.0 | 117 | 7/7/2024 |
1.3.2 | 4,648 | 3/10/2024 |
1.3.1 | 3,491 | 12/20/2023 |
1.3.0 | 359 | 11/24/2023 |
1.2.7 | 1,606 | 10/8/2023 |
1.2.6 | 436 | 9/10/2023 |
1.2.5 | 222 | 8/27/2023 |
1.2.4 | 2,148 | 7/30/2023 |
1.2.3 | 680 | 6/10/2023 |