Skip to content

RunAssertions

Namespace AgentPrism.Testing · Assembly AgentPrism.Testing.dll

Assertions on a recorded run.

public sealed class RunAssertions

objectRunAssertions

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Each unmet assertion throws AgentPrismAssertionException and writes the expected and actual value in its message. Streaming runs are covered too: run_events fills in on the streaming path as well, no separate type is needed.

The run’s event stream, in sequence order.

public IReadOnlyList<RunEvent> Events { get; }

IReadOnlyList<RunEvent>

The run record.

public RunRecord Record { get; }

RunRecord

Tool calls made during the run.

public IReadOnlyList<ToolInvocationRecord> ToolInvocations { get; }

IReadOnlyList<ToolInvocationRecord>

Asserts that a specific tool was called.

public RunAssertions ShouldHaveCalledTool(string toolName, int? times = null)

toolName string

Tool name.

times int?

If given, the exact number of calls expected.

RunAssertions

The chain, for continued assertions.

AgentPrismAssertionException

The tool was never called, or the count does not match.

Asserts that the run completed successfully.

public RunAssertions ShouldHaveCompleted()

RunAssertions

The chain, for continued assertions.

AgentPrismAssertionException

The status is not RunStatus.Completed.

Asserts that the run ended with a failure.

public RunAssertions ShouldHaveFailed()

RunAssertions

The chain, for continued assertions.

AgentPrismAssertionException

The status is not RunStatus.Failed.

Asserts that the run ended with a specific error type.

public RunAssertions ShouldHaveFailedWith(string errorType)

errorType string

The value expected to match AgentPrismException.ErrorType.

RunAssertions

The chain, for continued assertions.

AgentPrismAssertionException

The status is not RunStatus.Failed, or the error type does not match.

Asserts that the run’s generated text contains a specific substring.

public RunAssertions ShouldHaveOutputContaining(string text)

text string

Substring to look for.

RunAssertions

The chain, for continued assertions.

If a RunEventType.MessageCompleted exists (non-streaming run) it is used; otherwise (a streaming run, e.g. the HTTP /run endpoint) the RunEventType.MessageDelta chunks are concatenated. The two are never both present in the same run — also summing the chunks on the non-streaming path would DUPLICATE the text.

AgentPrismAssertionException

The substring was not found.

Asserts that a specific tool was never called.

public RunAssertions ShouldNotHaveCalledTool(string toolName)

toolName string

Tool name.

RunAssertions

The chain, for continued assertions.

AgentPrismAssertionException

The tool was called at least once.