![]() |
VOOZH | about |
dotnet add package Enigmatry.Entry.AspNetCore.Tests.Utilities --version 10.2.3
NuGet\Install-Package Enigmatry.Entry.AspNetCore.Tests.Utilities -Version 10.2.3
<PackageReference Include="Enigmatry.Entry.AspNetCore.Tests.Utilities" Version="10.2.3" />
<PackageVersion Include="Enigmatry.Entry.AspNetCore.Tests.Utilities" Version="10.2.3" />Directory.Packages.props
<PackageReference Include="Enigmatry.Entry.AspNetCore.Tests.Utilities" />Project file
paket add Enigmatry.Entry.AspNetCore.Tests.Utilities --version 10.2.3
#r "nuget: Enigmatry.Entry.AspNetCore.Tests.Utilities, 10.2.3"
#:package Enigmatry.Entry.AspNetCore.Tests.Utilities@10.2.3
#addin nuget:?package=Enigmatry.Entry.AspNetCore.Tests.Utilities&version=10.2.3Install as a Cake Addin
#tool nuget:?package=Enigmatry.Entry.AspNetCore.Tests.Utilities&version=10.2.3Install as a Cake Tool
A library that provides testing utilities and helpers for ASP.NET Core applications, making it easier to write clean, effective tests for web applications and APIs.
Use this library when you need to write tests for ASP.NET Core applications. It provides utilities for mocking HTTP contexts, working with controllers, testing middleware, and more.
Add the package to your project:
dotnet add package Enigmatry.Entry.AspNetCore.Tests.Utilities
Testing exception handling in a controller:
using Enigmatry.Entry.AspNetCore.Tests;
using Enigmatry.Entry.AspNetCore.Filters;
using Microsoft.AspNetCore.Mvc;
using NUnit.Framework;
using FakeItEasy;
using FluentValidation;
[TestFixture]
public class ExceptionHandlingTests
{ [Test]
public void HandleExceptionsFilter_ShouldReturnBadRequest_WhenValidationExceptionOccurs()
{
// Arrange
var exceptionContext = ExceptionContextBuilder.Create()
.WithValidationException()
.WithJsonRequest()
.Build();
var filter = new HandleExceptionsFilter();
// Act
filter.OnException(exceptionContext);
// Assert var result = exceptionContext.Result as BadRequestObjectResult;
Assert.That(result, Is.Not.Null);
Assert.That(result.Value, Is.Not.Null);
}
}
Testing HTTP contexts:
using Enigmatry.Entry.AspNetCore.Tests;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Diagnostics;
using NUnit.Framework;
[TestFixture]
public class HttpContextTests
{ [Test]
public void HttpContextBuilder_ShouldCreateValidContext_WithException()
{
// Arrange
var exception = new InvalidOperationException("Test exception");
// Act
var context = HttpContextBuilder.Create()
.With(exception)
.Build();
// Assert
var feature = context.Features.Get<IExceptionHandlerPathFeature>();
Assert.That(feature, Is.Not.Null);
Assert.That(feature.Error.Message, Is.EqualTo("Test exception"));
Assert.That(context.Request.Headers["Accept"], Is.EqualTo("application/json"));
}
}
using Enigmatry.Entry.AspNetCore.Tests.Utilities;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;
[TestFixture]
public class ServiceTests
{ [Test]
public void ServiceScope_ResolvesService_Successfully()
{
// Arrange
var services = new ServiceCollection();
services.AddScoped<IMyService, MyService>();
var provider = services.BuildServiceProvider();
// Act
using var scope = provider.CreateScope();
var service = scope.Resolve<IMyService>();
// Assert
Assert.That(service, Is.Not.Null);
Assert.That(service, Is.TypeOf<MyService>());
}
}
using Enigmatry.Entry.AspNetCore.Tests.Utilities.Database;
using Microsoft.Data.SqlClient;
using NUnit.Framework;
[TestFixture]
public class DatabaseTests
{ [Test]
public void DatabaseHelpers_ProvidesDropAllSql()
{
// Arrange
var connectionString = "Server=(localdb)\\MSSQLLocalDB;Database=TestDb;Integrated Security=true";
// Act & Assert
Assert.NotNull(DatabaseHelpers.DropAllSql);
// Example of how you might use it in a real test
// using var connection = new SqlConnection(connectionString);
// connection.Open();
// var command = new SqlCommand(DatabaseHelpers.DropAllSql, connection);
// command.ExecuteNonQuery();
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. 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. |
Showing the top 2 NuGet packages that depend on Enigmatry.Entry.AspNetCore.Tests.Utilities:
| Package | Downloads |
|---|---|
|
Enigmatry.Entry.AspNetCore.Tests.SystemTextJson
Building Block for writing tests in an Entry AspNetCore based project with SystemText Json |
|
|
Enigmatry.Entry.AspNetCore.Tests.NewtonsoftJson
Building Block for writing tests in an Entry AspNetCore based project with Newtonsoft Json |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.2.3 | 155 | 6/1/2026 |
| 10.2.3-preview.4 | 60 | 6/1/2026 |
| 10.2.2 | 372 | 4/27/2026 |
| 10.2.1-preview.1 | 57 | 4/27/2026 |
| 10.1.0 | 291 | 4/16/2026 |
| 10.0.1 | 188 | 5/19/2026 |
| 10.0.1-preview.2 | 66 | 4/16/2026 |
| 10.0.0 | 142 | 4/2/2026 |
| 9.6.0 | 544 | 3/18/2026 |
| 9.5.0 | 1,256 | 1/26/2026 |
| 9.4.0 | 1,792 | 12/22/2025 |
| 9.3.1-preview.3 | 271 | 12/18/2025 |
| 9.3.1-preview.1 | 508 | 11/25/2025 |
| 9.3.0 | 1,210 | 11/10/2025 |
| 9.2.0 | 1,553 | 9/24/2025 |
| 9.1.1-preview.5 | 243 | 8/8/2025 |
| 9.1.1-preview.4 | 145 | 6/27/2025 |
| 8.3.1-preview.1 | 214 | 12/24/2025 |
| 8.3.0 | 1,199 | 12/23/2025 |
| 8.2.0 | 461 | 9/24/2025 |