Trax.Core.Testing
1.8.0
Prefix Reserved
dotnet add package Trax.Core.Testing --version 1.8.0
NuGet\Install-Package Trax.Core.Testing -Version 1.8.0
<PackageReference Include="Trax.Core.Testing" Version="1.8.0" />
<PackageVersion Include="Trax.Core.Testing" Version="1.8.0" />
<PackageReference Include="Trax.Core.Testing" />
paket add Trax.Core.Testing --version 1.8.0
#r "nuget: Trax.Core.Testing, 1.8.0"
#:package Trax.Core.Testing@1.8.0
#addin nuget:?package=Trax.Core.Testing&version=1.8.0
#tool nuget:?package=Trax.Core.Testing&version=1.8.0
Trax.Core
Part of Trax: business logic you can call, schedule, or serve as an API, with every run recorded in your Postgres. Docs · Getting started · All repos
Trax.Core defines trains for .NET. A train is a typed pipeline of small steps (junctions): when a junction throws, the rest are skipped and the train returns the exception. It has no database and no DI container, and the other Trax layers build on it.
Install
dotnet add package Trax.Core
dotnet add package Trax.Core.Testing # optional: architecture-guard fixtures for your NUnit tests
Trax.Core targets .NET 10.
Example
using LanguageExt;
using Trax.Core.Junction;
using Trax.Core.Train;
public record CreateUserRequest(string Email);
public record User(Guid Id, string Email);
public class ValidateEmailJunction : Junction<CreateUserRequest, Unit>
{
public override Task<Unit> Run(CreateUserRequest input)
{
if (!input.Email.Contains('@'))
throw new ArgumentException($"'{input.Email}' is not an email address");
return Task.FromResult(Unit.Default);
}
}
public class CreateUserJunction : Junction<CreateUserRequest, User>
{
public override Task<User> Run(CreateUserRequest input) =>
Task.FromResult(new User(Guid.NewGuid(), input.Email));
}
public class CreateUserTrain : Train<CreateUserRequest, User>
{
protected override Task<Either<Exception, User>> Junctions() =>
Chain<ValidateEmailJunction>()
.Chain<CreateUserJunction>()
.Resolve();
}
Run it with RunEither, which never throws, and read the Either:
Either<Exception, User> result = await new CreateUserTrain().RunEither(new CreateUserRequest("ada@example.com"));
string message = result.Match(
Right: user => $"created {user.Id}",
Left: ex => $"failed: {ex.Message}");
If ValidateEmailJunction throws, CreateUserJunction never runs and result holds the exception. Run returns the
User directly and rethrows instead.
Where this fits
Trax is split into layers, one repo each. Take the ones you need; the trains you wrote do not change. You are here: Trax.Core.
| Repo | What it adds |
|---|---|
| Trax.Core | Trains, junctions and the chain, with no database and no DI container |
| Trax.Effect | A recorded run for every execution (Postgres, SQLite or in memory), DI, effect providers, the state-machine engine |
| Trax.Mediator | The train bus: run a train by handing over its input, with every chain checked at startup |
| Trax.Scheduler | Cron and interval schedules, retries, dead letters, and workers on other machines or in Lambda |
| Trax.Api | GraphQL generated from your trains, with authentication, audit and typed clients |
| Trax.Dashboard | A Blazor Server UI for runs, schedules and dead letters, mounted in your app |
| Trax.Cli | The trax tool: scaffold a hub and trains from an OpenAPI or GraphQL schema, and state-machine codegen |
| Trax.Samples | Complete sample apps, and the trax-api, trax-scheduler and trax-hub templates |
Docs live in Trax.Docs and are published at traxsharp.net/docs.
Contributing
Read AGENTS.md before changing code. Report vulnerabilities privately as described in SECURITY.md.
License
MIT. There is no commercial edition, and there will not be one.
Trax is an independent open-source project and is not affiliated with the Utah Transit Authority, Trax Retail, or any other organization using the Trax name.
| Product | Versions 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. |
-
net10.0
- Microsoft.CodeAnalysis.CSharp (>= 5.9.0)
- NUnit (>= 4.4.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Trax.Core.Testing:
| Package | Downloads |
|---|---|
|
Trax.Effect.Data.Testing
Architecture-guard checkers for the Trax data layer (DomainDataContext, one-schema-per-context, cross-schema reads). Framework-agnostic: returns offender lists you assert on. |
|
|
Trax.Api.GraphQL.Testing
Architecture-guard checkers for Trax GraphQL: cross-schema edge manifest validity and edge-resolver placement / loader use. Framework-agnostic: returns offender lists you assert on. |
|
|
Trax.Mediator.Testing
Architecture-guard checkers for Trax trains: every ServiceTrain has its companion I{Name} interface. Framework-agnostic: returns offender lists you assert on. |
GitHub repositories
This package is not used by any popular GitHub repositories.