Path: redb-route/tests/redb.Route.Tests.Sql/E2E/Infrastructure/Outcome.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.Sql/E2E/Infrastructure/Outcome.cs
----
namespace redb.Route.Tests.Sql.E2E.Infrastructure;
///
/// Runs an operation whose failure is the observed fact, not a test error: the exception is returned so the
/// test can assert on it. Nothing is swallowed — every caller asserts on the result.
///
public static class Outcome
{
/// The exception the operation threw, or null when it completed.
public static async Task Of(Func operation)
{
try
{
await operation();
return null;
}
catch (Exception ex)
{
return ex;
}
}
/// Short description for assertion messages.
public static string Describe(Exception? exception) =>
exception is null ? "no exception" : $"{exception.GetType().Name}: {exception.Message.Split('\n')[0].Trim()}";
}