Table of Contents

Class InstrumentCaptureAssertions

Namespace
MetricsAssertions.TUnit
Assembly
MetricsAssertions.TUnit.dll

TUnit-native fluent Assert.That(capture).Has* assertions over a single-instrument InstrumentCapture: counter and up-down-counter totals, measurement counts, last value, and tag presence. Generated via the TUnit [GenerateAssertion] source generator (AOT-clean).

public static class InstrumentCaptureAssertions
Inheritance
InstrumentCaptureAssertions
Inherited Members

Methods

HasCounterTotal(InstrumentCapture, long)

Asserts the net total of the captured counter equals expected.

[GenerateAssertion]
public static AssertionResult HasCounterTotal(this InstrumentCapture value, long expected)

Parameters

value InstrumentCapture

The instrument capture, as the receiver of the fluent assertion.

expected long

The expected net total.

Returns

AssertionResult

A passing assertion when the total matches; otherwise a failing one naming both values.

Exceptions

ArgumentNullException

value is null.

HasCounterTotalAtLeast(InstrumentCapture, long)

Asserts the net total of the captured counter is at least expected.

[GenerateAssertion]
public static AssertionResult HasCounterTotalAtLeast(this InstrumentCapture value, long expected)

Parameters

value InstrumentCapture

The instrument capture.

expected long

The minimum expected net total.

Returns

AssertionResult

A passing assertion when the total is at least the expected; otherwise a failing one.

Exceptions

ArgumentNullException

value is null.

HasLastValue(InstrumentCapture, double)

Asserts the most recently captured value equals expected.

[GenerateAssertion]
public static AssertionResult HasLastValue(this InstrumentCapture value, double expected)

Parameters

value InstrumentCapture

The instrument capture.

expected double

The expected last value.

Returns

AssertionResult

A passing assertion when the last value matches; otherwise a failing one (also failing when no measurements were captured).

Exceptions

ArgumentNullException

value is null.

HasLastValue(InstrumentCapture, double, double)

Asserts the most recently captured value equals expected within tolerance (absolute), the tolerant counterpart of HasLastValue(InstrumentCapture, double) for gauges fed computed doubles.

[GenerateAssertion]
public static AssertionResult HasLastValue(this InstrumentCapture value, double expected, double tolerance)

Parameters

value InstrumentCapture

The instrument capture.

expected double

The expected last value.

tolerance double

The allowed absolute difference.

Returns

AssertionResult

A passing assertion when the last value is within tolerance; otherwise a failing one (also failing when no measurements were captured).

Exceptions

ArgumentNullException

value is null.

ArgumentOutOfRangeException

tolerance is negative or non-finite.

HasMeasurementCount(InstrumentCapture, int)

Asserts that exactly expected measurements were captured.

[GenerateAssertion]
public static AssertionResult HasMeasurementCount(this InstrumentCapture value, int expected)

Parameters

value InstrumentCapture

The instrument capture.

expected int

The expected number of captured measurements.

Returns

AssertionResult

A passing assertion when the count matches; otherwise a failing one naming both counts.

Exceptions

ArgumentNullException

value is null.

HasNoMeasurements(InstrumentCapture)

Asserts that no measurements were captured.

[GenerateAssertion]
public static AssertionResult HasNoMeasurements(this InstrumentCapture value)

Parameters

value InstrumentCapture

The instrument capture.

Returns

AssertionResult

A passing assertion when the capture is empty; otherwise a failing one naming the count.

Exceptions

ArgumentNullException

value is null.

HasTaggedMeasurement(InstrumentCapture, string, object?)

Asserts at least one captured measurement carries a tag tagKey equal to tagValue.

[GenerateAssertion]
public static AssertionResult HasTaggedMeasurement(this InstrumentCapture value, string tagKey, object? tagValue)

Parameters

value InstrumentCapture

The instrument capture.

tagKey string

The tag key to match.

tagValue object

The tag value to match.

Returns

AssertionResult

A passing assertion when a matching measurement exists; otherwise a failing one.

Exceptions

ArgumentNullException

value or tagKey is null.

HasUpDownCounterValue(InstrumentCapture, long)

Asserts the net value of the captured up-down counter equals expected.

[GenerateAssertion]
public static AssertionResult HasUpDownCounterValue(this InstrumentCapture value, long expected)

Parameters

value InstrumentCapture

The instrument capture.

expected long

The expected net value.

Returns

AssertionResult

A passing assertion when the value matches; otherwise a failing one naming both values.

Exceptions

ArgumentNullException

value is null.