Unit

Functional-First Testing

Traditional .NET test frameworks model tests as void methods whose assertions communicate failure by throwing exceptions. That design works well for isolated assertions, but makes composing multiple checks, streaming async results, and building custom runners awkward.

ZeUnit takes a functional-first approach: a test is a regular public instance method that returns a result (Fact, Task<Fact>, IEnumerable<Fact>, or IObservable<Fact>).

No Test Attributes Required

Any public instance method on a discovered class whose return type matches one of ZeUnit's supported runner return types is automatically discovered as a test—no [Fact] or [Test] attribute is needed.

public class MathSuite
{
    public Fact AddsNumbers() => (2 + 2).Is(4);

    public async Task<Fact> ComputesAsynchronously()
    {
        await Task.Yield();
        return "ZeUnit".StartsWithText("Ze");
    }

    public IEnumerable<Fact> ValidatesBatch()
    {
        yield return 10.IsGreaterThan(5);
        yield return "abc".HasCount(3);
    }

    public IObservable<Fact> StreamsResults() =>
        Observable.Range(1, 3).Select(x => x.IsGreaterThan(0));
}

Values In, Facts Out

Instead of throwing on the first failed check, ZeUnit assertion extensions return Fact or Fact<T> values that accumulate ZeAssert entries (AssertPassed, AssertFailed, AssertError, AssertSkipped). Because each fluent call passes the value through, you can chain multiple checks cleanly:

public Fact ValidatesOrder()
{
    var items = new[] { "widget", "gadget" };
    return items
        .IsNotNull()
        .HasCount(2)
        .HasItem("widget");
}

If an assertion in the chain fails, Fact records the failed ZeAssert entry while continuing through the chain so reporters receive complete diagnostics.

Implicit Conversions

Returning bool or (bool Outcome, string Message) from a test method implicitly converts to Fact, giving you lightweight one-line checks alongside rich fluent assertions.

Composing Behavior Instead of Base Classes

Because tests are pure return-value functions and dependencies are injected through class constructors via ZeComposerAttribute<TComposer> and method parameters via ZeBinderAttribute<TBinder>, test code stays focused on behavior rather than test-harness plumbing.

See Facts & Assertions for the full assertion catalog, or Class Composers and Method Binders to learn how inputs flow into tests.