VOOZH about

URL: https://www.nuget.org/packages/E13.Common.Nunit.Api/

⇱ NuGet Gallery | E13.Common.Nunit.Api 2025.117.22




👁 Image
E13.Common.Nunit.Api 2025.117.22

dotnet add package E13.Common.Nunit.Api --version 2025.117.22
 
 
NuGet\Install-Package E13.Common.Nunit.Api -Version 2025.117.22
 
 
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="E13.Common.Nunit.Api" Version="2025.117.22" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="E13.Common.Nunit.Api" Version="2025.117.22" />
 
Directory.Packages.props
<PackageReference Include="E13.Common.Nunit.Api" />
 
Project file
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 E13.Common.Nunit.Api --version 2025.117.22
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: E13.Common.Nunit.Api, 2025.117.22"
 
 
#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.
#:package E13.Common.Nunit.Api@2025.117.22
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=E13.Common.Nunit.Api&version=2025.117.22
 
Install as a Cake Addin
#tool nuget:?package=E13.Common.Nunit.Api&version=2025.117.22
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

E13.Common.Nunit.Api

👁 NuGet Version
👁 License: MIT

Overview

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.

Features

  • API Test Fixtures: Base classes for API testing with TestServer integration
  • Launch Settings Integration: Automatic loading of launchSettings.json for test configuration
  • HTTP Client Extensions: Helper methods for working with HttpClient in tests
  • Azure AD Authentication: Utilities for authenticating with Azure AD in tests
  • Test Environment Management: Tools for managing test environments and configurations

Installation

dotnet add package E13.Common.Nunit.Api

Usage

Creating an API Test Fixture

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 Authentication in Tests

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();
 }
}

Required Environment Variables

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"
 }
 }
 }
}

Dependencies

  • .NET 9.0
  • Microsoft.AspNetCore.TestHost
  • Microsoft.Extensions.Hosting
  • PuppeteerSharp (for UI testing integration)
  • E13.Common.Api
  • E13.Common.Nunit

Related Packages

E13.Common.Nunit.Api is part of the E13.Common collection, which includes:

  • E13.Common.Core - Core utilities and base classes
  • E13.Common.Nunit - Base NUnit testing utilities
  • E13.Common.Nunit.UI - NUnit utilities for UI testing
  • E13.Common.Api - Web API layer components
  • E13.Common.AspNet - ASP.NET shared components

Contributing

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.

License

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. 
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
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
Loading failed