Table of Contents

Class HasNotLoggedAssertion

Namespace
LogAssertions.TUnit
Assembly
LogAssertions.TUnit.dll

TUnit assertion that verifies a Microsoft.Extensions.Logging.Testing.FakeLogCollector does not contain matching log records. Inherits filter chaining from LogAssertionBase<TSelf>; the expectation is fixed at zero matches (no terminators).

[AssertionExtension("HasNotLogged")]
public sealed class HasNotLoggedAssertion : LogAssertionBase<HasNotLoggedAssertion>, IAssertion
Inheritance
Assertion<FakeLogCollector>
HasNotLoggedAssertion
Implements
IAssertion
Inherited Members
Assertion<FakeLogCollector>.AssertAsync()
Assertion<FakeLogCollector>.GetAwaiter()
Assertion<FakeLogCollector>.And
Assertion<FakeLogCollector>.Or

Constructors

HasNotLoggedAssertion(AssertionContext<FakeLogCollector>)

Initialises a negative log assertion. Called by the TUnit source generator.

public HasNotLoggedAssertion(AssertionContext<FakeLogCollector> context)

Parameters

context AssertionContext<FakeLogCollector>

The assertion context supplied by TUnit.

Methods

CheckAsync(EvaluationMetadata<FakeLogCollector>)

Implements the specific check logic for this assertion. Called after the context has been evaluated. Override this method if your assertion uses the default AssertAsync() flow. If you override AssertAsync() with custom logic (like AndAssertion/OrAssertion), you don't need to implement this.

protected override Task<AssertionResult> CheckAsync(EvaluationMetadata<FakeLogCollector> metadata)

Parameters

metadata EvaluationMetadata<FakeLogCollector>

Metadata about the evaluation including value, exception, and timing information

Returns

Task<AssertionResult>

The result of the assertion check

GetExpectation()

Gets a human-readable description of what this assertion expects. Used in error messages.

protected override string GetExpectation()

Returns

string