Class AssertAllExtensions
- Namespace
- LogAssertions.TUnit
- Assembly
- LogAssertions.TUnit.dll
Batch-assertion entry point that runs multiple independent assertions against the same
Microsoft.Extensions.Logging.Testing.FakeLogCollector in a single pass and reports all failures together,
rather than failing fast on the first one. Conceptually similar to TUnit's own
Assert.Multiple, scoped specifically to log assertions.
public static class AssertAllExtensions
- Inheritance
-
AssertAllExtensions
- Inherited Members
Methods
AssertAllAsync<TActual>(IAssertionSource<TActual>, params Func<IAssertionSource<TActual>, Task>[])
Runs every assertions against the underlying collector. If any
throws, all failures are gathered and re-thrown as a single TUnit.Assertions.Exceptions.AssertionException
whose message lists each failure in order. Useful when several independent invariants
must all hold and the test author wants to see every violation in one CI run, not just
the first.
public static Task AssertAllAsync<TActual>(this IAssertionSource<TActual> source, params Func<IAssertionSource<TActual>, Task>[] assertions) where TActual : FakeLogCollector
Parameters
sourceIAssertionSource<TActual>The assertion source over a Microsoft.Extensions.Logging.Testing.FakeLogCollector.
assertionsFunc<IAssertionSource<TActual>, Task>[]The assertion lambdas; each receives the source and returns a Task.
Returns
- Task
A task that completes when all assertions have run.
Type Parameters
TActualThe actual type carried by the assertion source.
Exceptions
- ArgumentNullException
A required argument is null.
- AssertionException
One or more inner assertions failed; the message aggregates all failures.
AssertAllAsync<TActual>(IAssertionSource<TActual>, params Func<IAssertionSource<TActual>, Assertion<FakeLogCollector>>[])
Ergonomic overload that accepts assertion-builder configurators (returning the
fluent assertion object directly) instead of awaited delegates. Drops the
async/await boilerplate from every entry:
await Assert.That(c).AssertAllAsync(
c => c.HasLogged().AtLevel(LogLevel.Information).AtLeast(1),
c => c.HasNotLogged().AtLevel(LogLevel.Error));
instead of:
await Assert.That(c).AssertAllAsync(
async c => await c.HasLogged().AtLevel(LogLevel.Information).AtLeast(1),
async c => await c.HasNotLogged().AtLevel(LogLevel.Error));
The TUnit.Assertions.Core.Assertion<TValue> base type is itself awaitable; this overload awaits each returned assertion internally. Failure-aggregation semantics are identical to the AssertAllAsync<TActual>(IAssertionSource<TActual>, params Func<IAssertionSource<TActual>, Task>[]) overload.
public static Task AssertAllAsync<TActual>(this IAssertionSource<TActual> source, params Func<IAssertionSource<TActual>, Assertion<FakeLogCollector>>[] assertions) where TActual : FakeLogCollector
Parameters
sourceIAssertionSource<TActual>The assertion source over a Microsoft.Extensions.Logging.Testing.FakeLogCollector.
assertionsFunc<IAssertionSource<TActual>, Assertion<FakeLogCollector>>[]The assertion configurators; each receives the source and returns the configured fluent assertion.
Returns
- Task
A task that completes when all assertions have run.
Type Parameters
TActualThe actual type carried by the assertion source.
Exceptions
- ArgumentNullException
A required argument is null.
- AssertionException
One or more inner assertions failed; the message aggregates all failures.