![]() |
VOOZH | about |
dotnet add package E13.Common.Nunit.Api --version 2025.117.22
NuGet\Install-Package E13.Common.Nunit.Api -Version 2025.117.22
<PackageReference Include="E13.Common.Nunit.Api" Version="2025.117.22" />
<PackageVersion Include="E13.Common.Nunit.Api" Version="2025.117.22" />Directory.Packages.props
<PackageReference Include="E13.Common.Nunit.Api" />Project file
paket add E13.Common.Nunit.Api --version 2025.117.22
#r "nuget: E13.Common.Nunit.Api, 2025.117.22"
#:package E13.Common.Nunit.Api@2025.117.22
#addin nuget:?package=E13.Common.Nunit.Api&version=2025.117.22Install as a Cake Addin
#tool nuget:?package=E13.Common.Nunit.Api&version=2025.117.22Install as a Cake Tool
👁 NuGet Version
👁 License: MIT
E13.Common.Nunit.Api is a specialized package within the E13.Common collection designed for testing Web API projects with NUnit. It extends E13.Common.Nunit with API-specific testing utilities, including test server integration, HTTP client extensions, and authentication helpers.
dotnet add package E13.Common.Nunit.Api
using E13.Common.Nunit.Api;
using Microsoft.AspNetCore.Hosting;
using NUnit.Framework;
using System.Net.Http;
// Create a test fixture for your API
public class MyApiTests : BaseApiFixture
{
public MyApiTests()
: base("MyApi.Project", () => new WebHostBuilder().UseStartup<TestStartup>())
{
}
[Test]
public async Task GetEndpoint_ReturnsSuccessStatusCode()
{
// Get the configured HttpClient
var client = GetHttpClient();
// Make a request to your API
var response = await client.GetAsync("/api/values");
// Assert the response
response.EnsureSuccessStatusCode();
}
}
using E13.Common.Nunit.Api;
using NUnit.Framework;
using System.Net.Http;
public class AuthenticatedApiTests
{
private HttpClient _client;
[SetUp]
public void Setup()
{
_client = new HttpClient();
}
[Test]
public async Task SecureEndpoint_WithAuthentication_ReturnsSuccessStatusCode()
{
// Authenticate with Azure AD using environment variables
_client.TokenForAAD_TestEnabled(new[] { "api://my-api/access" });
// Make a request to a secure endpoint
var response = await _client.GetAsync("https://my-api.example.com/secure");
// Assert the response
response.EnsureSuccessStatusCode();
}
}
For Azure AD authentication tests, set these environment variables in your launchSettings.json:
{
"profiles": {
"MyTests": {
"commandName": "Project",
"environmentVariables": {
"TokenForAAD_PublicClientId": "your-client-id",
"TokenForAAD_TenantId": "your-tenant-id",
"TokenForAAD_TestUser": "test.user@example.com",
"TokenForAAD_TestPass": "your-test-password"
}
}
}
}
E13.Common.Nunit.Api is part of the E13.Common collection, which includes:
Contributions to E13.Common.Nunit.Api are welcome. If you have suggestions or improvements, please submit an issue or create a pull request in the GitHub repository.
This project is licensed under the MIT License. For more details, see the LICENSE file in the repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2025.117.22 | 229 | 4/27/2025 |
| 2025.114.21 | 259 | 4/24/2025 |
| 2025.114.20 | 235 | 4/24/2025 |
| 2025.114.18 | 266 | 4/24/2025 |
| 2025.112.17 | 276 | 4/22/2025 |
| 2025.112.16 | 238 | 4/22/2025 |
| 2025.111.15 | 246 | 4/21/2025 |
| 2025.106.14 | 277 | 4/16/2025 |
| 2025.106.12 | 319 | 4/16/2025 |
| 2025.97.11 | 250 | 4/7/2025 |
| 2025.96.9 | 266 | 4/6/2025 |
| 2025.96.8 | 252 | 4/6/2025 |
| 2025.91.7 | 243 | 4/1/2025 |
| 2025.91.6 | 239 | 4/1/2025 |
| 2025.90.4 | 265 | 3/31/2025 |
| 2023.30.1 | 476 | 1/30/2023 |
| 2023.18.1 | 413 | 1/18/2023 |
| 2021.324.4 | 1,737 | 11/20/2021 |
| 2021.124.2 | 770 | 5/4/2021 |
| 1.0.0 | 236 | 4/1/2025 |