ArturRios.Util.Test 2.0.0

dotnet add package ArturRios.Util.Test --version 2.0.0
                    
NuGet\Install-Package ArturRios.Util.Test -Version 2.0.0
                    
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="ArturRios.Util.Test" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ArturRios.Util.Test" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="ArturRios.Util.Test" />
                    
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 ArturRios.Util.Test --version 2.0.0
                    
#r "nuget: ArturRios.Util.Test, 2.0.0"
                    
#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 ArturRios.Util.Test@2.0.0
                    
#: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=ArturRios.Util.Test&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=ArturRios.Util.Test&version=2.0.0
                    
Install as a Cake Tool

Test Util

Docs License: MIT NuGet

ArturRios.Util.Test is a small .NET library of test-support utilities for xUnit projects. It bundles the helpers that come up again and again when testing services and web APIs: extra assertions, environment-aware test attributes, in-memory fakes for repositories and schedulers, and a base class for functional web API tests.

Installation

dotnet add package ArturRios.Util.Test

The package targets net10.0 and builds on other ArturRios.* packages (ArturRios.Util, ArturRios.Data, ArturRios.Mediator, ArturRios.Configuration and ArturRios.Util.WebApi) plus xunit and Microsoft.AspNetCore.Mvc.Testing.

What's inside

Component Role
CustomAssert Extra xUnit assertions for null/empty checks on collections and strings
UnitFactAttribute, UnitTheoryAttribute, FunctionalFactAttribute, FunctionalTheoryAttribute Test attributes that can skip tests per environment or on a condition
FakeRepository<T> In-memory ICrudRepository<T> / IRangeRepository<T> implementation
FakeScheduler Simulates a delayed command/query dispatch through a CommandQueryMediator
WebApiTest<T> Base class for functional web API tests using an in-memory host
TestException Exception raised by the utilities when a test-support operation fails

Quick Start

Custom assertions

CustomAssert.NullOrEmpty(collection);      // passes for null or empty
CustomAssert.NotNullOrEmpty(collection);   // passes only for a non-empty collection
CustomAssert.NullOrWhiteSpace(text);
CustomAssert.NotNullOrWhiteSpace(text);

Environment-aware attributes

// Runs everywhere except Production.
[UnitFact([EnvironmentType.Production])]
public void Calculates_totals() { /* ... */ }

// Skipped whenever the condition is true, on any environment.
[FunctionalFact(skipCondition: FeatureFlags.PaymentsDisabled)]
public void Charges_card() { /* ... */ }

In-memory repository

var repository = new FakeRepository<Person>();

var id = repository.Create(new Person { Name = "Ann" });   // ids start at 1
var person = repository.GetById(id);
repository.Update(new Person { Id = id, Name = "Ann Smith" });
repository.Delete(new Person { Id = id });

Functional web API test

public class ProductsApiTests : WebApiTest<Program>
{
    public ProductsApiTests() : base(EnvironmentType.Local) { }

    [Fact]
    public async Task Creates_a_product()
    {
        await AuthenticateAndAuthorizeAsync(new Credentials("user@test.com", "secret123"), "/auth");

        var response = await Gateway.PostAsync<DataOutput<ProductOutput>>("/products", new { Name = "Widget" });

        Assert.Equal(HttpStatusCode.OK, response.StatusCode);
    }
}

Documentation

Full documentation, with per-component guides, lives at artur-rios.github.io/dotnet-test-util:

Versioning

Semantic Versioning (SemVer). Breaking changes result in a new major version. New methods or non-breaking behavior changes increment the minor version; fixes or tweaks increment the patch.

Build, test and publish

Use the official .NET CLI to build, test and publish the project and Git for source control. If you want, optional helper toolsets I built to facilitate these tasks are available:

This project is licensed under the MIT License. A copy of the license is available at LICENSE in the repository.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

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 41 7/23/2026
1.0.0 87 7/15/2026