Table of Contents

Class MeterCaptureAssertions

Namespace
MetricsAssertions.TUnit
Assembly
MetricsAssertions.TUnit.dll

TUnit-native fluent Assert.That(meter).Has* assertions over a multi-instrument MeterCapture, addressing one bundled instrument by name. Generated via the TUnit [GenerateAssertion] source generator (AOT-clean).

public static class MeterCaptureAssertions
Inheritance
MeterCaptureAssertions
Inherited Members

Methods

HasCounterTotal(MeterCapture, string, long)

Asserts the net total of a bundled counter equals expected.

[GenerateAssertion]
public static AssertionResult HasCounterTotal(this MeterCapture value, string instrumentName, long expected)

Parameters

value MeterCapture

The meter capture.

instrumentName string

The counter instrument name.

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 or instrumentName is null.

HasMeasurementCount(MeterCapture, string, int)

Asserts the measurement count for a bundled instrument equals expected.

[GenerateAssertion]
public static AssertionResult HasMeasurementCount(this MeterCapture value, string instrumentName, int expected)

Parameters

value MeterCapture

The meter capture.

instrumentName string

The instrument name.

expected int

The expected measurement count.

Returns

AssertionResult

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

Exceptions

ArgumentNullException

value or instrumentName is null.

HasTaggedMeasurement(MeterCapture, string, string, object?)

Asserts a bundled instrument has at least one measurement tagged tagKey equal to tagValue.

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

Parameters

value MeterCapture

The meter capture.

instrumentName string

The instrument name.

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, instrumentName, or tagKey is null.

HasUpDownCounterValue(MeterCapture, string, long)

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

[GenerateAssertion]
public static AssertionResult HasUpDownCounterValue(this MeterCapture value, string instrumentName, long expected)

Parameters

value MeterCapture

The meter capture.

instrumentName string

The up-down-counter instrument name.

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 or instrumentName is null.