MockException Class

Moq 2.6

Exception thrown by mocks when expectations are not met, the mock is not properly setup, etc.

Namespace:  Moq
Assembly:  Moq (in Moq.dll) Version: 2.6.1014.1 (2.6.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

Object
  Exception
    Moq..::.MockException

See Also