Click or drag to resize
ErrorTester Class
A class that tests that actions throw expected exceptions.
Inheritance Hierarchy
SystemObject
  Capgemini.CommonObjectUtils.TestingErrorTester

Namespace: Capgemini.CommonObjectUtils.Testing
Assembly: Capgemini.CommonObjectUtils (in Capgemini.CommonObjectUtils.dll) Version: 1.3.0.0
Syntax
public class ErrorTester

The ErrorTester type exposes the following members.

Constructors
  NameDescription
Public methodErrorTester
Initializes a new instance of the ErrorTester class
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodTest
Tests that an action causes a specified exception.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks
You can use this class (as an alternative to the ExpectedException attribute) when you have several test cases that should all throw an exception and you want to group them together into a single unit test method.
Examples
[TestMethod]
public void MyNullArgumentTest() 
{
    ...
    new ErrorTester()
        .Test(typeof(ArgumentNullException), () => {myObj.myMethod(null, "1");})
        .Test(typeof(ArgumentNullException), () => {myObj.myMethod("2", null);});
}
See Also