Class MeasurementSetAssertions
- Namespace
- MetricsAssertions.TUnit
- Assembly
- MetricsAssertions.TUnit.dll
TUnit-native fluent Assert.That(set).Has* assertions over a MeasurementSet:
counter totals, measurement counts, emptiness, histogram sample sum / average / range, exact and
order-insensitive sample sets, and tag-consistency. Narrow first with
Tagged(string, object?) / ForInstrument(string) to
assert a dimension. Generated via the TUnit [GenerateAssertion] source generator (AOT-clean).
public static class MeasurementSetAssertions
- Inheritance
-
MeasurementSetAssertions
- Inherited Members
Methods
HasAllSamplesInRange(MeasurementSet, double, double)
Asserts every sample lies within the inclusive range [min,
max].
[GenerateAssertion]
public static AssertionResult HasAllSamplesInRange(this MeasurementSet value, double min, double max)
Parameters
valueMeasurementSetThe measurement set.
mindoubleThe inclusive lower bound.
maxdoubleThe inclusive upper bound.
Returns
- AssertionResult
A passing assertion when every sample is in range; otherwise a failing one.
Exceptions
- ArgumentNullException
valueis null.
HasCounterTotal(MeasurementSet, long)
Asserts the net total of the values equals expected.
[GenerateAssertion]
public static AssertionResult HasCounterTotal(this MeasurementSet value, long expected)
Parameters
valueMeasurementSetThe measurement set.
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(MeasurementSet, long)
Asserts the net total of the values is at least expected.
[GenerateAssertion]
public static AssertionResult HasCounterTotalAtLeast(this MeasurementSet value, long expected)
Parameters
valueMeasurementSetThe measurement set.
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.
HasEveryMeasurementTagged(MeasurementSet, string)
Asserts every measurement carries a tag with key tagKey.
[GenerateAssertion]
public static AssertionResult HasEveryMeasurementTagged(this MeasurementSet value, string tagKey)
Parameters
valueMeasurementSetThe measurement set.
tagKeystringThe tag key that must be present on every measurement.
Returns
- AssertionResult
A passing assertion when every measurement is tagged; otherwise a failing one.
Exceptions
- ArgumentNullException
valueortagKeyis null.
HasMeasurementCount(MeasurementSet, int)
Asserts the number of measurements equals expected.
[GenerateAssertion]
public static AssertionResult HasMeasurementCount(this MeasurementSet value, int expected)
Parameters
valueMeasurementSetThe measurement set.
expectedintThe expected measurement count.
Returns
- AssertionResult
A passing assertion when the count matches; otherwise a failing one naming both counts.
Exceptions
- ArgumentNullException
valueis null.
HasNoMeasurements(MeasurementSet)
Asserts the set is empty.
[GenerateAssertion]
public static AssertionResult HasNoMeasurements(this MeasurementSet value)
Parameters
valueMeasurementSetThe measurement set.
Returns
- AssertionResult
A passing assertion when the set is empty; otherwise a failing one naming the count.
Exceptions
- ArgumentNullException
valueis null.
HasSampleAverage(MeasurementSet, double, double)
Asserts the mean of the histogram samples equals expected (within
tolerance).
[GenerateAssertion]
public static AssertionResult HasSampleAverage(this MeasurementSet value, double expected, double tolerance = 0)
Parameters
valueMeasurementSetThe measurement set.
expecteddoubleThe expected average.
tolerancedoubleThe allowed absolute difference (exact by default).
Returns
- AssertionResult
A passing assertion when the average is within tolerance; otherwise a failing one.
Exceptions
- ArgumentNullException
valueis null.
HasSampleSum(MeasurementSet, double, double)
Asserts the sum of the histogram samples equals expected (within
tolerance).
[GenerateAssertion]
public static AssertionResult HasSampleSum(this MeasurementSet value, double expected, double tolerance = 0)
Parameters
valueMeasurementSetThe measurement set.
expecteddoubleThe expected sum.
tolerancedoubleThe allowed absolute difference (exact by default).
Returns
- AssertionResult
A passing assertion when the sum is within tolerance; otherwise a failing one.
Exceptions
- ArgumentNullException
valueis null.
HasSamples(MeasurementSet, IReadOnlyList<double>, double)
Asserts the samples equal expected in order, each within
tolerance (absolute), the tolerant counterpart of
HasSamples(MeasurementSet, params double[]) for samples fed computed doubles.
[GenerateAssertion]
public static AssertionResult HasSamples(this MeasurementSet value, IReadOnlyList<double> expected, double tolerance)
Parameters
valueMeasurementSetThe measurement set.
expectedIReadOnlyList<double>The expected samples, in order.
tolerancedoubleThe allowed absolute difference per sample.
Returns
- AssertionResult
A passing assertion when the samples match in order within tolerance; otherwise a failing one.
Exceptions
- ArgumentNullException
valueorexpectedis null.- ArgumentOutOfRangeException
toleranceis negative or non-finite.
HasSamples(MeasurementSet, params double[])
Asserts the samples equal expected in order.
[GenerateAssertion]
public static AssertionResult HasSamples(this MeasurementSet value, params double[] expected)
Parameters
valueMeasurementSetThe measurement set.
expecteddouble[]The expected samples, in order.
Returns
- AssertionResult
A passing assertion when the samples match in order; otherwise a failing one.
Exceptions
- ArgumentNullException
valueorexpectedis null.
HasSamplesInAnyOrder(MeasurementSet, IReadOnlyList<double>, double)
Asserts the samples equal expected regardless of order, each within
tolerance (absolute), the tolerant counterpart of
HasSamplesInAnyOrder(MeasurementSet, params double[]) for samples fed computed doubles.
[GenerateAssertion]
public static AssertionResult HasSamplesInAnyOrder(this MeasurementSet value, IReadOnlyList<double> expected, double tolerance)
Parameters
valueMeasurementSetThe measurement set.
expectedIReadOnlyList<double>The expected samples, in any order.
tolerancedoubleThe allowed absolute difference per sample.
Returns
- AssertionResult
A passing assertion when the samples match in any order within tolerance; otherwise a failing one.
Exceptions
- ArgumentNullException
valueorexpectedis null.- ArgumentOutOfRangeException
toleranceis negative or non-finite.
HasSamplesInAnyOrder(MeasurementSet, params double[])
Asserts the samples equal expected regardless of order.
[GenerateAssertion]
public static AssertionResult HasSamplesInAnyOrder(this MeasurementSet value, params double[] expected)
Parameters
valueMeasurementSetThe measurement set.
expecteddouble[]The expected samples, in any order.
Returns
- AssertionResult
A passing assertion when the samples match in any order; otherwise a failing one.
Exceptions
- ArgumentNullException
valueorexpectedis null.
HasTaggedMeasurement(MeasurementSet, string, object?)
Asserts at least one measurement carries a tag tagKey equal to
tagValue.
[GenerateAssertion]
public static AssertionResult HasTaggedMeasurement(this MeasurementSet value, string tagKey, object? tagValue)
Parameters
valueMeasurementSetThe measurement set.
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.