Skip to content

Get Sansar

Script API

Assertions

Where: Client
More page actions

For the complete documentation index, see llms.txt. This page is also available as Markdown.

Class Namespace Sansar.Script.Testing

Contains various test methods which throw exceptions if the conditions are false.

public static class Assertions

Remarks

This class is restricted and may not be included in scripts for sale in the marketplace. All APIs are subject to change.

Members at a glance

KindMembers
PropertiesLogSuccessful
MethodsAlmostEqual · Equal · Fail · Greater · NotEqual · NotNull · Null · NullOrMissing · True · Type

Properties

LogSuccessful

public static bool LogSuccessful { get; set; }

Enables or disables logging of successful assertion diagnostic messages.

Remarks

This can be used to trace test execution.

Methods

AlmostEqual

public static void AlmostEqual(     Sansar.Quaternion a,     Sansar.Quaternion b,     int significantFigures,     string diagnostic,     [System.Runtime.CompilerServices.CallerMemberName] string memberName,     [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath,     [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber )

Throws an exception if the two Quaternions are not approximately equal.

ParameterTypeDescription
aSansar.QuaternionThe first Quaternion to check.
bSansar.QuaternionThe second Quaternion to check.
significantFiguresintThe number of significant digits to compare
diagnosticstringOptional string to show with a faulure exception.
memberNamestringgenerated by the compiler
sourceFilePathstringgenerated by the compiler
sourceLineNumberintgenerated by the compiler
Remarks

The method is restricted. The method is subject to change or removal at any time and may not be included in scripts for sale in the marketplace.

public static void AlmostEqual(     Sansar.Vector a,     Sansar.Vector b,     int significantFigures,     string diagnostic,     [System.Runtime.CompilerServices.CallerMemberName] string memberName,     [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath,     [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber )

Throws an exception if the two vectors are not approximately equal.

ParameterTypeDescription
aSansar.VectorThe first vector to check.
bSansar.VectorThe second vector to check.
significantFiguresintThe number of significant digits to compare
diagnosticstringOptional string to show with a faulure exception.
memberNamestringgenerated by the compiler
sourceFilePathstringgenerated by the compiler
sourceLineNumberintgenerated by the compiler
Remarks

The method is restricted. The method is subject to change or removal at any time and may not be included in scripts for sale in the marketplace.

public static void AlmostEqual(     float a,     float b,     int significantFigures,     string diagnostic,     [System.Runtime.CompilerServices.CallerMemberName] string memberName,     [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath,     [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber )

Throws an exception if the two floats are not approximately equal.

ParameterTypeDescription
afloatThe first float to check.
bfloatThe second float to check.
significantFiguresintThe number of significant digits to compare
diagnosticstringOptional string to show with a faulure exception.
memberNamestringgenerated by the compiler
sourceFilePathstringgenerated by the compiler
sourceLineNumberintgenerated by the compiler
Remarks

The method is restricted. The method is subject to change or removal at any time and may not be included in scripts for sale in the marketplace.

Equal

public static void Equal<T>(     T a,     T b,     string diagnostic,     [System.Runtime.CompilerServices.CallerMemberName] string memberName,     [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath,     [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber ) where T : IComparable

Throws an exception if the passed objects do not compare as equal via IComparable.CompareTo. Will NOT throw if both objects are null.

ParameterTypeDescription
aTThe first object to check.
bTThe second object to check.
diagnosticstringOptional string to show with a faulure exception.
memberNamestringgenerated by the compiler
sourceFilePathstringgenerated by the compiler
sourceLineNumberintgenerated by the compiler

Type parameters: T: The type of the objects.

Remarks

The method is restricted. The method is subject to change or removal at any time and may not be included in scripts for sale in the marketplace.

Fail

public static void Fail(     string diagnostic,     [System.Runtime.CompilerServices.CallerMemberName] string memberName,     [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath,     [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber )

Throws an exception always.

ParameterTypeDescription
diagnosticstringOptional string to show with a faulure exception.
memberNamestringgenerated by the compiler
sourceFilePathstringgenerated by the compiler
sourceLineNumberintgenerated by the compiler
Remarks

The method is restricted. The method is subject to change or removal at any time and may not be included in scripts for sale in the marketplace.

Greater

public static void Greater<T>(     T a,     T b,     string diagnostic,     [System.Runtime.CompilerServices.CallerMemberName] string memberName,     [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath,     [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber ) where T : IComparable

Throws an exception if the first object does not compare as greater via IComparable.CompareTo.

ParameterTypeDescription
aTThe first object to check.
bTThe second object to check.
diagnosticstringOptional string to show with a faulure exception.
memberNamestringgenerated by the compiler
sourceFilePathstringgenerated by the compiler
sourceLineNumberintgenerated by the compiler

Type parameters: T: The type of the objects.

Remarks

The method is restricted. The method is subject to change or removal at any time and may not be included in scripts for sale in the marketplace.

NotEqual

public static void NotEqual<T>(     T a,     T b,     string diagnostic,     [System.Runtime.CompilerServices.CallerMemberName] string memberName,     [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath,     [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber ) where T : IComparable

Throws an exception if the passed objects compare as equal via IComparable.CompareTo.

ParameterTypeDescription
aTThe first object to check.
bTThe second object to check.
diagnosticstringOptional string to show with a faulure exception.
memberNamestringgenerated by the compiler
sourceFilePathstringgenerated by the compiler
sourceLineNumberintgenerated by the compiler

Type parameters: T: The type of the objects.

Remarks

The method is restricted. The method is subject to change or removal at any time and may not be included in scripts for sale in the marketplace.

NotNull

public static void NotNull(     object val,     string diagnostic,     [System.Runtime.CompilerServices.CallerMemberName] string memberName,     [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath,     [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber )

Throws an exception if the passed argument is not null.

ParameterTypeDescription
valobjectThe value that must be null.
diagnosticstringOptional string to show with a faulure exception.
memberNamestringgenerated by the compiler
sourceFilePathstringgenerated by the compiler
sourceLineNumberintgenerated by the compiler
Remarks

The method is restricted. The method is subject to change or removal at any time and may not be included in scripts for sale in the marketplace.

Null

public static void Null(     object val,     string diagnostic,     [System.Runtime.CompilerServices.CallerMemberName] string memberName,     [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath,     [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber )

Throws an exception if the passed argument is not null.

ParameterTypeDescription
valobjectThe value that must be null.
diagnosticstringOptional string to show with a faulure exception.
memberNamestringgenerated by the compiler
sourceFilePathstringgenerated by the compiler
sourceLineNumberintgenerated by the compiler
Remarks

The method is restricted. The method is subject to change or removal at any time and may not be included in scripts for sale in the marketplace.

NullOrMissing

public static void NullOrMissing(     string message,     string contents,     string diagnostic,     [System.Runtime.CompilerServices.CallerMemberName] string memberName,     [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath,     [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber )

Throws an exception if the message is non-null and contains the contents substring.

ParameterTypeDescription
messagestringThe message to check.
contentsstringA substring to check.
diagnosticstringOptional string to show with a faulure exception.
memberNamestringgenerated by the compiler
sourceFilePathstringgenerated by the compiler
sourceLineNumberintgenerated by the compiler
Remarks

The method is restricted. The method is subject to change or removal at any time and may not be included in scripts for sale in the marketplace.

True

public static void True(     bool val,     string diagnostic,     [System.Runtime.CompilerServices.CallerMemberName] string memberName,     [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath,     [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber )

Throws an exception if the passed argument is false.

ParameterTypeDescription
valboolThe value that must be true.
diagnosticstringOptional string to show with a faulure exception.
memberNamestringgenerated by the compiler
sourceFilePathstringgenerated by the compiler
sourceLineNumberintgenerated by the compiler
Remarks

The method is restricted. The method is subject to change or removal at any time and may not be included in scripts for sale in the marketplace.

Type

public static void Type(     string typename,     object obj,     string diagnostic,     [System.Runtime.CompilerServices.CallerMemberName] string memberName,     [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath,     [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber )

Throws an exception if the Type.FullName of the passed object does not match the passed typename.

ParameterTypeDescription
typenamestringThe expected typename.
objobjectThe object to check.
diagnosticstringOptional string to show with a faulure exception.
memberNamestringgenerated by the compiler
sourceFilePathstringgenerated by the compiler
sourceLineNumberintgenerated by the compiler
Remarks

The method is restricted. The method is subject to change or removal at any time and may not be included in scripts for sale in the marketplace.

public static void Type<T>(     object obj,     string diagnostic,     [System.Runtime.CompilerServices.CallerMemberName] string memberName,     [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath,     [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber )

Throws an exception if the passed type is not of the same type as the type param or if the obj is null.

ParameterTypeDescription
objobjectThe object to check.
diagnosticstringOptional string to show with a faulure exception.
memberNamestringgenerated by the compiler
sourceFilePathstringgenerated by the compiler
sourceLineNumberintgenerated by the compiler

Type parameters: T: The type to confirm.

Remarks

The method is restricted. The method is subject to change or removal at any time and may not be included in scripts for sale in the marketplace.

Generated from the Sansar 47.10.0 client ScriptApi snapshot.