System.Reactive

Shell
dotnet add package Nullean.Entities.Reactive
dotnet add package Nullean.Entities.CsCheck.Reactive
  1. rules on a live IObservable<T>
  2. tests only: generated scripts on a virtual Rx clock

The core package and the default CsCheck package do not depend on System.Reactive. A service that records timestamped events is tested without it (see Time and events). Add these packages when the service is built on observables.

  • Nullean.Entities.Reactive attaches a set of named rules to an IObservable<TEvent> and gives a verdict per rule, Pending, Holds or Violated, as events arrive: "was Shipped ever emitted after Cancelled?", "did every placed order ship within an hour?". It is trim and NativeAOT clean.

    C#
    var spec = ReactiveConstraintSet.From(("never-shipped-after-cancellation",
        Never<OrderEvent.Cancelled, OrderEvent.Shipped>((c, s) => c.OrderId == s.OrderId)));
    
    MonitoredConstraintSet<OrderEvent> monitored = spec.Attach(events);
    
    1. monitored.AnyViolated, monitored.Violations
  • Nullean.Entities.CsCheck.Reactive runs a generated Script<TSut> against the service on a HistoricalScheduler that the generated delays advance, then checks the rules against the events it emitted. A 48-hour deadline is tested without waiting, and a failure comes back as the shortest call sequence with a seed:

    C#
    script.SampleWith(scheduler => new Shipments(scheduler), s => s.Events, shipsWithinAMinute);
    

The terminals and their options are in Rx scripts.