Table of Contents

Class Assert

Namespace
Antithesis.SDK
Assembly
Antithesis.SDK.dll

The Assert class enables defining test properties about your program or workload.

Each static method in this class takes a parameter called message, which is a string literal identifier used to aggregate assertions. Antithesis generates one test property per unique message. This test property will be named message in the triage report.

Each static method also takes a parameter called details, which is an optional JsonObject reference of additional information provided by the caller to add context to assertion passes and failures. The information that is logged will appear in the logs section of a triage report.

public static class Assert
Inheritance
Assert
Inherited Members

Methods

Always(bool, string, JsonObject?)

Assert that condition is true every time this method is called, and that it is called at least once (i.e. the corresponding test property will fail if the assertion is never encountered).

The corresponding test property will be viewable in the Antithesis SDK: Always assertions group of your triage report.

public static void Always(bool condition, string message, JsonObject? details = null)

Parameters

condition bool

The condition being asserted.

message string

A unique string identifier of the assertion. Provides context for assertion passes and failures and is intended to be human-readable. Must be provided as a string literal or as a reference to a publicly accessible const field.

details JsonObject

Optional additional details to provide greater context for assertion passes and failures.

AlwaysGreaterThanOrEqualTo<T>(T, T, string, JsonObject?)

AlwaysGreaterThanOrEqualTo(left, right, ...) is mostly equivalent to Always(left >= right, ...) but additionally provides Antithesis visibility into the value of left and right by merging them into the assertion's details.

public static void AlwaysGreaterThanOrEqualTo<T>(T left, T right, string message, JsonObject? details = null) where T : struct, IComparable<T>, IConvertible

Parameters

left T

The left operand of the comparison.

right T

The right operand of the comparison.

message string
A unique string identifier of the assertion. Provides context for assertion passes and failures and is intended to be human-readable. Must be provided as a string literal or as a reference to a publicly accessible const field.
details JsonObject
Optional additional details to provide greater context for assertion passes and failures.

Type Parameters

T

The numeric type that we are comparing.

See Also

AlwaysGreaterThan<T>(T, T, string, JsonObject?)

AlwaysGreaterThan(left, right, ...) is mostly equivalent to Always(left > right, ...) but additionally provides Antithesis visibility into the value of left and right by merging them into the assertion's details.

public static void AlwaysGreaterThan<T>(T left, T right, string message, JsonObject? details = null) where T : struct, IComparable<T>, IConvertible

Parameters

left T

The left operand of the comparison.

right T

The right operand of the comparison.

message string
A unique string identifier of the assertion. Provides context for assertion passes and failures and is intended to be human-readable. Must be provided as a string literal or as a reference to a publicly accessible const field.
details JsonObject
Optional additional details to provide greater context for assertion passes and failures.

Type Parameters

T

The numeric type that we are comparing.

See Also

AlwaysLessThanOrEqualTo<T>(T, T, string, JsonObject?)

AlwaysLessThanOrEqualTo(left, right, ...) is mostly equivalent to Always(left <= right, ...) but additionally provides Antithesis visibility into the value of left and right by merging them into the assertion's details.

public static void AlwaysLessThanOrEqualTo<T>(T left, T right, string message, JsonObject? details = null) where T : struct, IComparable<T>, IConvertible

Parameters

left T

The left operand of the comparison.

right T

The right operand of the comparison.

message string
A unique string identifier of the assertion. Provides context for assertion passes and failures and is intended to be human-readable. Must be provided as a string literal or as a reference to a publicly accessible const field.
details JsonObject
Optional additional details to provide greater context for assertion passes and failures.

Type Parameters

T

The numeric type that we are comparing.

See Also

AlwaysLessThan<T>(T, T, string, JsonObject?)

AlwaysLessThan(left, right, ...) is mostly equivalent to Always(left < right, ...) but additionally provides Antithesis visibility into the value of left and right by merging them into the assertion's details.

public static void AlwaysLessThan<T>(T left, T right, string message, JsonObject? details = null) where T : struct, IComparable<T>, IConvertible

Parameters

left T

The left operand of the comparison.

right T

The right operand of the comparison.

message string
A unique string identifier of the assertion. Provides context for assertion passes and failures and is intended to be human-readable. Must be provided as a string literal or as a reference to a publicly accessible const field.
details JsonObject
Optional additional details to provide greater context for assertion passes and failures.

Type Parameters

T

The numeric type that we are comparing.

See Also

AlwaysOrUnreachable(bool, string, JsonObject?)

Assert that condition is true every time this method is called. The corresponding test property will pass if the assertion is never encountered.

The corresponding test property will be viewable in the Antithesis SDK: Always assertions group of your triage report.

public static void AlwaysOrUnreachable(bool condition, string message, JsonObject? details = null)

Parameters

condition bool

The condition being asserted.

message string

A unique string identifier of the assertion. Provides context for assertion passes and failures and is intended to be human-readable. Must be provided as a string literal or as a reference to a publicly accessible const field.

details JsonObject

Optional additional details to provide greater context for assertion passes and failures.

AlwaysSome(IReadOnlyDictionary<string, bool>, string, JsonObject?)

AlwaysSome({ ["key1"] = bool1, ["key2"] = bool2 }, ...) is similar to Always(bool1 || bool2, ...) but additionally provides Antithesis visibility into the keys and values of conditions by merging them into the assertion's details.

public static void AlwaysSome(IReadOnlyDictionary<string, bool> conditions, string message, JsonObject? details = null)

Parameters

conditions IReadOnlyDictionary<string, bool>

The collection of conditions to-be evaluated, represented as a Dictionary of bools keyed by strings.

message string
A unique string identifier of the assertion. Provides context for assertion passes and failures and is intended to be human-readable. Must be provided as a string literal or as a reference to a publicly accessible const field.
details JsonObject
Optional additional details to provide greater context for assertion passes and failures.
See Also

Reachable(string, JsonObject?)

Assert that a line of code is reached at least once. The corresponding test property will fail if the assertion is never encountered.

This test property will be viewable in the Antithesis SDK: Reachability assertions group of your triage report.

public static void Reachable(string message, JsonObject? details = null)

Parameters

message string

A unique string identifier of the assertion. Provides context for assertion passes and failures and is intended to be human-readable. Must be provided as a string literal or as a reference to a publicly accessible const field.

details JsonObject

Optional additional details to provide greater context for assertion passes and failures.

Sometimes(bool, string, JsonObject?)

Assert that condition is true at least one time that this method was called. The corresponding test property will fail if the assertion is never encountered.

This test property will be viewable in the Antithesis SDK: Sometimes assertions group of your triage report.

public static void Sometimes(bool condition, string message, JsonObject? details = null)

Parameters

condition bool

The condition being asserted.

message string

A unique string identifier of the assertion. Provides context for assertion passes and failures and is intended to be human-readable. Must be provided as a string literal or as a reference to a publicly accessible const field.

details JsonObject

Optional additional details to provide greater context for assertion passes and failures.

SometimesAll(IReadOnlyDictionary<string, bool>, string, JsonObject?)

SometimesAll({ ["key1"] = bool1, ["key2"] = bool2 }, ...) is similar to Sometimes(bool1 && bool2, ...) but additionally provides Antithesis visibility into the keys and values of conditions by merging them into the assertion's details.

public static void SometimesAll(IReadOnlyDictionary<string, bool> conditions, string message, JsonObject? details = null)

Parameters

conditions IReadOnlyDictionary<string, bool>

The collection of conditions to-be evaluated, represented as a Dictionary of bools keyed by strings.

message string
A unique string identifier of the assertion. Provides context for assertion passes and failures and is intended to be human-readable. Must be provided as a string literal or as a reference to a publicly accessible const field.
details JsonObject
Optional additional details to provide greater context for assertion passes and failures.
See Also

SometimesGreaterThanOrEqualTo<T>(T, T, string, JsonObject?)

SometimesGreaterThanOrEqualTo(left, right, ...) is mostly equivalent to Sometimes(left >= right, ...) but additionally provides Antithesis visibility into the value of left and right by merging them into the assertion's details.

public static void SometimesGreaterThanOrEqualTo<T>(T left, T right, string message, JsonObject? details = null) where T : struct, IComparable<T>, IConvertible

Parameters

left T

The left operand of the comparison.

right T

The right operand of the comparison.

message string
A unique string identifier of the assertion. Provides context for assertion passes and failures and is intended to be human-readable. Must be provided as a string literal or as a reference to a publicly accessible const field.
details JsonObject
Optional additional details to provide greater context for assertion passes and failures.

Type Parameters

T

The numeric type that we are comparing.

See Also

SometimesGreaterThan<T>(T, T, string, JsonObject?)

SometimesGreaterThan(left, right, ...) is mostly equivalent to Sometimes(left > right, ...) but additionally provides Antithesis visibility into the value of left and right by merging them into the assertion's details.

public static void SometimesGreaterThan<T>(T left, T right, string message, JsonObject? details = null) where T : struct, IComparable<T>, IConvertible

Parameters

left T

The left operand of the comparison.

right T

The right operand of the comparison.

message string
A unique string identifier of the assertion. Provides context for assertion passes and failures and is intended to be human-readable. Must be provided as a string literal or as a reference to a publicly accessible const field.
details JsonObject
Optional additional details to provide greater context for assertion passes and failures.

Type Parameters

T

The numeric type that we are comparing.

See Also

SometimesLessThanOrEqualTo<T>(T, T, string, JsonObject?)

SometimesLessThanOrEqualTo(left, right, ...) is mostly equivalent to Sometimes(left <= right, ...) but additionally provides Antithesis visibility into the value of left and right by merging them into the assertion's details.

public static void SometimesLessThanOrEqualTo<T>(T left, T right, string message, JsonObject? details = null) where T : struct, IComparable<T>, IConvertible

Parameters

left T

The left operand of the comparison.

right T

The right operand of the comparison.

message string
A unique string identifier of the assertion. Provides context for assertion passes and failures and is intended to be human-readable. Must be provided as a string literal or as a reference to a publicly accessible const field.
details JsonObject
Optional additional details to provide greater context for assertion passes and failures.

Type Parameters

T

The numeric type that we are comparing.

See Also

SometimesLessThan<T>(T, T, string, JsonObject?)

SometimesLessThan(left, right, ...) is mostly equivalent to Sometimes(left < right, ...) but additionally provides Antithesis visibility into the value of left and right by merging them into the assertion's details.

public static void SometimesLessThan<T>(T left, T right, string message, JsonObject? details = null) where T : struct, IComparable<T>, IConvertible

Parameters

left T

The left operand of the comparison.

right T

The right operand of the comparison.

message string
A unique string identifier of the assertion. Provides context for assertion passes and failures and is intended to be human-readable. Must be provided as a string literal or as a reference to a publicly accessible const field.
details JsonObject
Optional additional details to provide greater context for assertion passes and failures.

Type Parameters

T

The numeric type that we are comparing.

See Also

Unreachable(string, JsonObject?)

Assert that a line of code is never reached. The corresponding test property will pass if and only if the assertion is never encountered.

This test property will be viewable in the Antithesis SDK: Reachability assertions group of your triage report.

public static void Unreachable(string message, JsonObject? details = null)

Parameters

message string

A unique string identifier of the assertion. Provides context for assertion passes and failures and is intended to be human-readable. Must be provided as a string literal or as a reference to a publicly accessible const field.

details JsonObject

Optional additional details to provide greater context for assertion passes and failures.