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
valueInstrumentCaptureThe instrument capture, as the receiver of the fluent assertion.
expectedlongThe expected net total.
Returns
- AssertionResult
A passing assertion when the total matches; otherwise a failing one naming both values.
Exceptions
- ArgumentNullException
valueis 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
valueInstrumentCaptureThe instrument capture.
expectedlongThe minimum expected net total.
Returns
- AssertionResult
A passing assertion when the total is at least the expected; otherwise a failing one.
Exceptions
- ArgumentNullException
valueis null.
HasLastValue(InstrumentCapture, double)
Asserts the most recently captured value equals expected.
[GenerateAssertion]
public static AssertionResult HasLastValue(this InstrumentCapture value, double expected)
Parameters
valueInstrumentCaptureThe instrument capture.
expecteddoubleThe 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
valueis 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
valueInstrumentCaptureThe instrument capture.
expecteddoubleThe expected last value.
tolerancedoubleThe 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
valueis null.- ArgumentOutOfRangeException
toleranceis 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
valueInstrumentCaptureThe instrument capture.
expectedintThe expected number of captured measurements.
Returns
- AssertionResult
A passing assertion when the count matches; otherwise a failing one naming both counts.
Exceptions
- ArgumentNullException
valueis null.
HasNoMeasurements(InstrumentCapture)
Asserts that no measurements were captured.
[GenerateAssertion]
public static AssertionResult HasNoMeasurements(this InstrumentCapture value)
Parameters
valueInstrumentCaptureThe instrument capture.
Returns
- AssertionResult
A passing assertion when the capture is empty; otherwise a failing one naming the count.
Exceptions
- ArgumentNullException
valueis 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
valueInstrumentCaptureThe instrument capture.
tagKeystringThe tag key to match.
tagValueobjectThe tag value to match.
Returns
- AssertionResult
A passing assertion when a matching measurement exists; otherwise a failing one.
Exceptions
- ArgumentNullException
valueortagKeyis 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
valueInstrumentCaptureThe instrument capture.
expectedlongThe expected net value.
Returns
- AssertionResult
A passing assertion when the value matches; otherwise a failing one naming both values.
Exceptions
- ArgumentNullException
valueis null.