Skip to content

TestingUtils Methods

Collection of test utilities

CreateDefaultLoggerFactory(string)

static
View source
public static ILoggerFactory CreateDefaultLoggerFactory(string filePath)
Create the default logger factory, which would configure logger factory with a FileLoggerProvider that writes logs to filePath and console. by default;

Parameters

filePathstring
The file path.

Returns

ILoggerFactory.

CreateDefaultLoggerFactory(string, LoggerFilterOptions)

static
View source
public static ILoggerFactory CreateDefaultLoggerFactory(string filePath, LoggerFilterOptions filters)
Create the default logger factory, which would configure logger factory with a FileLoggerProvider that writes logs to filePath and console. by default;

Parameters

filePathstring
the logger file path
filtersLoggerFilterOptions
log filters you want to configure your logging with

CreateTraceFileName(string, string)

static
View source
public static string CreateTraceFileName(string nodeName, string clusterId)
Create trace file name for a specific node or client in a specific deployment

Parameters

nodeNamestring
Name of the node.
clusterIdstring
The cluster identifier.

Returns

The new trace file name.

Multiply(TimeSpan, double)

static
View source
public static TimeSpan Multiply(TimeSpan time, double value)
Multiply a timeout by a value

Parameters

timeTimeSpan
The time.
valuedouble
The value.

Returns

The resulting time span value.

WaitUntilAsync(Func<bool, CancellationToken, Task<bool>>, TimeSpan, TimeSpan?, CancellationToken, string?)

static
View source
public static Task WaitUntilAsync(Func<bool, CancellationToken, Task<bool>> predicate, TimeSpan timeout, TimeSpan? delayOnFail = null, CancellationToken cancellationToken = default(CancellationToken), string? predicateExpression = null)
Run the predicate until it succeeds or times out.

Parameters

predicateFunc<bool, CancellationToken, Task<bool>>
The predicate to run. The first argument indicates the final attempt, allowing the predicate to throw a detailed assertion failure. The token is cancelled when the deadline expires or cancellation is requested.
timeoutTimeSpan
The timeout value.
delayOnFailTimeSpan?
The delay before retrying after an unsuccessful attempt.
cancellationTokenCancellationToken
The cancellation token.
predicateExpressionstring?
The expression supplied for predicate.

Returns

A task representing the operation.

Exceptions

System.TimeoutException
The predicate did not succeed before the timeout elapsed.

WaitUntilAsync(Func<bool, Task<bool>>, TimeSpan, TimeSpan?)

static
View source
public static Task WaitUntilAsync(Func<bool, Task<bool>> predicate, TimeSpan timeout, TimeSpan? delayOnFail = null)
Run the predicate until it succeeds or times out.

Parameters

predicateFunc<bool, Task<bool>>
The predicate to run
timeoutTimeSpan
The timeout value
delayOnFailTimeSpan?
The time to delay next call upon failure

Returns

A task representing the operation.

Exceptions

System.TimeoutException
The predicate did not succeed before the timeout elapsed.

WaitUntilSucceededAsync(Func<CancellationToken, Task<bool>>, TimeSpan, TimeSpan?, CancellationToken)

static
View source
public static Task<bool> WaitUntilSucceededAsync(Func<CancellationToken, Task<bool>> predicate, TimeSpan timeout, TimeSpan? delayOnFail = null, CancellationToken cancellationToken = default(CancellationToken))
Runs the predicate until it succeeds or the monotonic deadline expires.

Parameters

predicateFunc<CancellationToken, Task<bool>>
The predicate to run. The token is cancelled when the deadline expires or cancellation is requested.
timeoutTimeSpan
The timeout value.
delayOnFailTimeSpan?
The delay before retrying after an unsuccessful attempt.
cancellationTokenCancellationToken
The cancellation token.

Returns

true if the predicate succeeded before the deadline; otherwise, false.