Class MockException
- Namespace
- Moq
- Assembly
- Moq.dll
Exception thrown by mocks when they are not properly set up, when setups are not matched, when verification fails, etc.
public class MockException : Exception, ISerializable
- Inheritance
-
MockException
- Implements
- Inherited Members
Remarks
A distinct exception type is provided so that exceptions thrown by a mock can be distinguished from other exceptions that might be thrown in tests.
Moq does not provide a richer hierarchy of exception types, as tests typically should not catch or expect exceptions from 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 disappear and allow the test to pass.
Constructors
MockException(SerializationInfo, StreamingContext)
Supports the serialization infrastructure.
protected MockException(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfoSerialization information.
contextStreamingContextStreaming context.
Properties
IsVerificationError
Indicates whether this exception is a verification fault raised by Verify()
public bool IsVerificationError { get; }
Property Value
Methods
GetObjectData(SerializationInfo, StreamingContext)
Supports the serialization infrastructure.
[SecurityCritical]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfoSerialization information.
contextStreamingContextStreaming context.