C# Класс Spring.Util.AssertUtils

Assertion utility methods that simplify things such as argument checks.

Not intended to be used directly by applications.

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
ArgumentHasElements ( ICollection argument, string name ) : void

Checks the value of the supplied ICollection argument and throws an ArgumentException if it is , contains no elements or only null elements.

ArgumentHasLength ( ICollection argument, string name ) : void

Checks the value of the supplied ICollection argument and throws an ArgumentNullException if it is or contains no elements.

ArgumentHasLength ( ICollection argument, string name, string message ) : void

Checks the value of the supplied ICollection argument and throws an ArgumentNullException if it is or contains no elements.

ArgumentHasText ( string argument, string name ) : void

Checks the value of the supplied string argument and throws an System.ArgumentNullException if it is or contains only whitespace character(s).

ArgumentHasText ( string argument, string name, string message ) : void

Checks the value of the supplied string argument and throws an System.ArgumentNullException if it is or contains only whitespace character(s).

ArgumentNotNull ( object argument, string name ) : void

Checks the value of the supplied argument and throws an System.ArgumentNullException if it is .

ArgumentNotNull ( object argument, string name, string message ) : void

Checks the value of the supplied argument and throws an System.ArgumentNullException if it is .

AssertArgumentType ( object argument, string argumentName, Type requiredType, string message ) : void

Checks whether the specified argument can be cast into the requiredType.

IsTrue ( bool expression ) : void

Assert a boolean expression, throwing ArgumentException if the test result is false.

IsTrue ( bool expression, string message ) : void

Assert a boolean expression, throwing ArgumentException if the test result is false.

State ( bool expression, string message ) : void

Assert a bool expression, throwing InvalidOperationException if the expression is false.

Understands ( object target, string targetName, MethodBase method ) : void

Checks, whether method may be invoked on target. Supports testing transparent proxies.

Understands ( object target, string targetName, Type requiredType ) : void

checks, whether target supports the methods of requiredType. Supports testing transparent proxies.

Приватные методы

Метод Описание
AssertUtils ( ) : System

Creates a new instance of the Spring.Util.AssertUtils class.

This is a utility class, and as such exposes no public constructors.

Описание методов

ArgumentHasElements() публичный статический Метод

Checks the value of the supplied ICollection argument and throws an ArgumentException if it is , contains no elements or only null elements.
/// If the supplied is , /// contains no elements or only null elements. ///
public static ArgumentHasElements ( ICollection argument, string name ) : void
argument ICollection The array or collection to check.
name string The argument name.
Результат void

ArgumentHasLength() публичный статический Метод

Checks the value of the supplied ICollection argument and throws an ArgumentNullException if it is or contains no elements.
/// If the supplied is or /// contains no elements. ///
public static ArgumentHasLength ( ICollection argument, string name ) : void
argument ICollection The array or collection to check.
name string The argument name.
Результат void

ArgumentHasLength() публичный статический Метод

Checks the value of the supplied ICollection argument and throws an ArgumentNullException if it is or contains no elements.
/// If the supplied is or /// contains no elements. ///
public static ArgumentHasLength ( ICollection argument, string name, string message ) : void
argument ICollection The array or collection to check.
name string The argument name.
message string An arbitrary message that will be passed to any thrown .
Результат void

ArgumentHasText() публичный статический Метод

Checks the value of the supplied string argument and throws an System.ArgumentNullException if it is or contains only whitespace character(s).
/// If the supplied is or /// contains only whitespace character(s). ///
public static ArgumentHasText ( string argument, string name ) : void
argument string The string to check.
name string The argument name.
Результат void

ArgumentHasText() публичный статический Метод

Checks the value of the supplied string argument and throws an System.ArgumentNullException if it is or contains only whitespace character(s).
/// If the supplied is or /// contains only whitespace character(s). ///
public static ArgumentHasText ( string argument, string name, string message ) : void
argument string The string to check.
name string The argument name.
message string /// An arbitrary message that will be passed to any thrown /// . ///
Результат void

ArgumentNotNull() публичный статический Метод

Checks the value of the supplied argument and throws an System.ArgumentNullException if it is .
/// If the supplied is . ///
public static ArgumentNotNull ( object argument, string name ) : void
argument object The object to check.
name string The argument name.
Результат void

ArgumentNotNull() публичный статический Метод

Checks the value of the supplied argument and throws an System.ArgumentNullException if it is .
/// If the supplied is . ///
public static ArgumentNotNull ( object argument, string name, string message ) : void
argument object The object to check.
name string The argument name.
message string /// An arbitrary message that will be passed to any thrown /// . ///
Результат void

AssertArgumentType() публичный статический Метод

Checks whether the specified argument can be cast into the requiredType.
public static AssertArgumentType ( object argument, string argumentName, Type requiredType, string message ) : void
argument object /// The argument to check. ///
argumentName string /// The name of the argument to check. ///
requiredType System.Type /// The required type for the argument. ///
message string /// An arbitrary message that will be passed to any thrown /// . ///
Результат void

IsTrue() публичный статический Метод

Assert a boolean expression, throwing ArgumentException if the test result is false.
/// if expression is false ///
public static IsTrue ( bool expression ) : void
expression bool a boolean expression.
Результат void

IsTrue() публичный статический Метод

Assert a boolean expression, throwing ArgumentException if the test result is false.
/// if expression is false ///
public static IsTrue ( bool expression, string message ) : void
expression bool a boolean expression.
message string The exception message to use if the assertion fails.
Результат void

State() публичный статический Метод

Assert a bool expression, throwing InvalidOperationException if the expression is false.
if expression is false
public static State ( bool expression, string message ) : void
expression bool a boolean expression.
message string The exception message to use if the assertion fails
Результат void

Understands() публичный статический Метод

Checks, whether method may be invoked on target. Supports testing transparent proxies.
/// if is null /// /// if it is not possible to invoke on ///
public static Understands ( object target, string targetName, MethodBase method ) : void
target object the target instance or null
targetName string the name of the target to be used in error messages
method System.Reflection.MethodBase the method to test for
Результат void

Understands() публичный статический Метод

checks, whether target supports the methods of requiredType. Supports testing transparent proxies.
/// if is null /// /// if it is not possible to invoke methods of /// type on ///
public static Understands ( object target, string targetName, Type requiredType ) : void
target object the target instance or null
targetName string the name of the target to be used in error messages
requiredType System.Type the type to test for
Результат void