MockException Class

Moq

Collapse imageExpand ImageCopy imageCopyHover image
Exception thrown by mocks when setups are not matched, the mock is not properly setup, etc.

Namespace: Moq
Assembly: Moq (in Moq.dll) Version: 4.0.10827.0 (4.0.0.0)

Syntax

C#
[SerializableAttribute]
public class MockException : Exception

Remarks

A distinct exception type is provided so that exceptions thrown by the mock can be differentiated in tests that expect other exceptions to be thrown (i.e. ArgumentException).

Richer exception hierarchy/types are not provided as tests typically should not catch or expect exceptions from the mocks. These are typically the result of changes in the tested class or its collaborators implementation, and result in fixes in the mock setup so that they dissapear and allow the test to pass.

Inheritance Hierarchy

System..::..Object
  System..::..Exception
    Moq..::..MockException

See Also