RunAssertions
AgentPrism.Testing.dllAssertions on a recorded run.
public sealed class RunAssertionsInheritance
Section titled “Inheritance”Inherited Members
Section titled “Inherited Members”object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”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.
Properties
Section titled “Properties”Events
Section titled “ Events”The run’s event stream, in sequence order.
public IReadOnlyList<RunEvent> Events { get; }Property Value
Section titled “Property Value”Record
Section titled “ Record”The run record.
public RunRecord Record { get; }Property Value
Section titled “Property Value”ToolInvocations
Section titled “ ToolInvocations”Tool calls made during the run.
public IReadOnlyList<ToolInvocationRecord> ToolInvocations { get; }Property Value
Section titled “Property Value”IReadOnlyList<ToolInvocationRecord>
Methods
Section titled “Methods”ShouldHaveCalledTool(string, int?)
Section titled “ ShouldHaveCalledTool(string, int?)”Asserts that a specific tool was called.
public RunAssertions ShouldHaveCalledTool(string toolName, int? times = null)Parameters
Section titled “Parameters”toolName string
Tool name.
times int?
If given, the exact number of calls expected.
Returns
Section titled “Returns”The chain, for continued assertions.
Exceptions
Section titled “Exceptions”The tool was never called, or the count does not match.
ShouldHaveCompleted()
Section titled “ ShouldHaveCompleted()”Asserts that the run completed successfully.
public RunAssertions ShouldHaveCompleted()Returns
Section titled “Returns”The chain, for continued assertions.
Exceptions
Section titled “Exceptions”The status is not RunStatus.Completed.
ShouldHaveFailed()
Section titled “ ShouldHaveFailed()”Asserts that the run ended with a failure.
public RunAssertions ShouldHaveFailed()Returns
Section titled “Returns”The chain, for continued assertions.
Exceptions
Section titled “Exceptions”The status is not RunStatus.Failed.
ShouldHaveFailedWith(string)
Section titled “ ShouldHaveFailedWith(string)”Asserts that the run ended with a specific error type.
public RunAssertions ShouldHaveFailedWith(string errorType)Parameters
Section titled “Parameters”errorType string
The value expected to match AgentPrismException.ErrorType.
Returns
Section titled “Returns”The chain, for continued assertions.
Exceptions
Section titled “Exceptions”The status is not RunStatus.Failed, or the error type does not match.
ShouldHaveOutputContaining(string)
Section titled “ ShouldHaveOutputContaining(string)”Asserts that the run’s generated text contains a specific substring.
public RunAssertions ShouldHaveOutputContaining(string text)Parameters
Section titled “Parameters”text string
Substring to look for.
Returns
Section titled “Returns”The chain, for continued assertions.
Remarks
Section titled “Remarks”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.
Exceptions
Section titled “Exceptions”The substring was not found.
ShouldNotHaveCalledTool(string)
Section titled “ ShouldNotHaveCalledTool(string)”Asserts that a specific tool was never called.
public RunAssertions ShouldNotHaveCalledTool(string toolName)Parameters
Section titled “Parameters”toolName string
Tool name.
Returns
Section titled “Returns”The chain, for continued assertions.
Exceptions
Section titled “Exceptions”The tool was called at least once.