IMockControl Interface

Typemock Isolator Developer Guide
IMockControl is the Typemock Isolator mock type controller, this interface is use for managing the virtual mocks

Namespace:  TypeMock
Assembly:  TypeMock (in TypeMock.dll) Version: 9.3.6.0 (9.3.6.0)
Syntax

public interface IMockControl

The IMockControl type exposes the following members.

Properties

  NameDescription
Public propertyCallBase
Allow mocking a method in a base class that is hidden by the mocked class
Public propertyValidateArgsOnVerify Obsolete.
Obsolete. Argument validation is done both on calling the method and during Verify. Postpone throwing validation errors till Verify is called
Top
Methods

  NameDescription
Public methodAlwaysCallOriginal
Indicate that the behavior of the mocked method will be to call the original method.
Public methodAlwaysReturn
Expect unlimited calls from method, and always returns mock value
Public methodAlwaysThrow
Expect unlimited calls from method, and always throws exception
Public methodCode exampleAnonymousMethodOf
Use to mock all anonymous methods that are called from within a method
Public methodCode exampleAssignField
Assign a new value to the given field.
Public methodClear
Clear all expectations
Public methodClear(String)
Clear expectation of a method
Public methodExpectAddEvent(String)
Expect 1 event listener to be added (event += new EventHandler())
Public methodExpectAddEvent(String, Int32)
Expect a number of event listeners to be added (event += new EventHandler())
Public methodExpectAddEventAlways
Expect unlimited number of event listeners to be added (event += new EventHandler())
Public methodExpectAlways
Expect unlimited calls from method
Public methodExpectAndReturn(String, Object, Type)
Expect 1 call from method, and mock return value
Public methodExpectAndReturn(String, Object, Int32, Type)
Expect a number of calls from method, and mock return value
Public methodExpectAndThrow(String, Exception, Type)
Expect 1 call from method, and mock throwing an exception
Public methodExpectAndThrow(String, Exception, Int32, Type)
Expect a number of calls from method, and mock throwing an exception
Public methodExpectCall(String, Type)
Expect 1 call from method
Public methodExpectCall(String, Int32, Type)
Expect a number of calls from method
Public methodExpectConstructor
Mock Constructor
Public methodExpectConstructor(Int32)
Mock Constructor
Public methodExpectConstructorAlways
Mock unlimited calls from Constructor
Public methodExpectConstructorAndThrow
Mock Constructor and throw exception when constructor is called
Public methodExpectGet(String, Object)
Expect 1 get of a Property and mock the Property's value
Public methodExpectGet(String, Object, Int32)
Expect a number of gets of a Property and mock the Property's value
Public methodExpectGetAlways
Expect unlimited get of a Property and always mock the Property's value
Public methodExpectGetAndAlwaysThrow
Expect unlimited get of a Property and always mock throwing an exception
Public methodExpectGetAndThrow(String, Exception)
Expect 1 get of a Property and mock throwing an exception
Public methodExpectGetAndThrow(String, Exception, Int32)
Expect a number of gets of a Property and mock throwing an exception
Public methodExpectGetIndex(Object)
Expect 1 get of an Index and mock the index value
Public methodExpectGetIndex(Object, Int32)
Expect a number of get of an Index and mock the index value
Public methodExpectGetIndexAlways
Expect unlimited set of an Index and mock throwing an exception
Public methodExpectGetIndexAndAlwaysThrow
Expect unlimited set of an Index and mock throwing an exception
Public methodExpectGetIndexAndThrow(Exception)
Expect 1 get of an Index and mock throwing an exception
Public methodExpectGetIndexAndThrow(Exception, Int32)
Expect a number of gets of an Index and mock throwing an exception
Public methodExpectRemoveEvent(String)
Expect 1 event listener to be removed (event -= new EventHandler())
Public methodExpectRemoveEvent(String, Int32)
Expect a number of event listeners to be removed (event -= new EventHandler())
Public methodExpectSet(String)
Expect 1 set of a Property
Public methodExpectSet(String, Int32)
Expect a number of sets of a Property
Public methodExpectSetAlways
Expect unlimited set of a Property
Public methodExpectSetAndAlwaysThrow
Expect unlimited set of a Property and always mock throwing an exception
Public methodExpectSetAndThrow(String, Exception)
Expect 1 set of a Property and mock throwing an exception
Public methodExpectSetAndThrow(String, Exception, Int32)
Expect a number of sets of a Property and mock throwing an exception
Public methodExpectSetIndex
Expect 1 set of an Index
Public methodExpectSetIndex(Int32)
Expect a number of sets of an Index
Public methodExpectSetIndexAlways
Expect unlimited set of an Index
Public methodExpectSetIndexAndAlwaysThrow
Expect unlimited set of an Index and mock throwing an exception
Public methodExpectSetIndexAndThrow(Exception)
Expect 1 set of an Index and mock throwing an exception
Public methodExpectSetIndexAndThrow(Exception, Int32)
Expect a number of sets of an Index and mock throwing an exception
Public methodExpectUnmockedCall(String, Type)
Verify 1 call from method , continue with method as normal
Public methodExpectUnmockedCall(String, Int32, Type)
Verify a number of calls from method , continue with method as normal
Public methodExpectUnmockedConstructor
Don't Mock Constructor but verify arguments
Public methodExpectUnmockedConstructor(Int32)
Don't Mock Constructor but verify arguments
Public methodExpectUnmockedGet(String)
Verify 1 get of a Property , continue with get method as normal
Public methodExpectUnmockedGet(String, Int32)
Verify a number of gets of a Property , continue with get method as normal
Public methodExpectUnmockedSet(String)
Verify 1 set of a Property , continue with set method as normal
Public methodExpectUnmockedSet(String, Int32)
Verify a number of sets of a Property , continue with set method as normal
Public methodMethodSettings
Perform Behavior tweaking on methods rather then the whole mocked type
Public methodMethodSettingsGetIndex
Perform Behavior tweaking on methods rather then the whole mocked type
Public methodMethodSettingsGetProperty
Perform Behavior tweaking on methods rather then the whole mocked type
Public methodMethodSettingsSetIndex
Perform Behavior tweaking on methods rather then the whole mocked type
Public methodMethodSettingsSetProperty
Perform Behavior tweaking on methods rather then the whole mocked type
Public methodCode exampleMockField
Create a Mock object and assign it to a given field.
Top
Remarks

Mock object have 3 stages.
  1. Set Up - This is the stage where you 'record' what the mocked type/object expects to do and what to return
  2. Run - Run the actual class under test
  3. Verify - Make sure that the mocked object acted as expected

These phases are managed by the IMockControl object.

Note Note
When mocking a method that is declared in a base class, Typemock Isolator will only mock that method when called from the mocked type. When a base method is mocked and a derived class calls that method, it WON'T be mocked

See Also

Reference