Mock Methods

Typemock Isolator Developer Guide

The Mock type exposes the following members.

Methods

  NameDescription
Public methodAlwaysCallOriginal
Sets the expectaion of this method to always call the original method.
Public methodAlwaysReturn(String, Object, Type)
Expect unlimited calls from method, and always returns mock value
Public methodAlwaysReturn(String, Object, Type, Type)
Expect unlimited calls from method, and always returns mock value
Public methodAlwaysThrow(String, Exception, Type)
Expect unlimited calls from method, and always throws exception
Public methodAlwaysThrow(String, Exception, Type, Type)
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.
Protected methodChangeConstructor
Constructer swaping with the mocked one, keep internal
Public methodClear
Clear all expectations
Public methodClear(String)
Clear expectation of a method
Public methodClear(ExpectationBlock)
Clear expectation of an expectation block
Public methodEndBlock
End an expectation block
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
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 methodExpectCallAndVerify Obsolete.
Verify 1 call from method , continue with method as normal
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
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 methodGetBlock
Retrieve Expectation Block, by its label name
Public methodGetCallCount(String)
Return the amount of times a method has been called
Public methodGetCallCount(String, Type)
Return the amount of times a method has been called
Public methodGetCallIndexerCounter
Return the amount of times an indexer has been called
Public methodGetCallPropertyGetCounter
Return the amount of times a property has been called
Public methodGetCallPropertySetCounter
Return the amount of times a property has been set
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 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 methodMockConstructor Obsolete.
Mock Constructor
Public methodCode exampleMockField
Create a Mock object and assign it to a given field.
Protected methodRemoveStaticCtor
Remobing static constructer, keep internal
Public methodStartBlock
Start an expectation block
Public methodStartBlock(String)
Start an expectation block with a label name
Public methodStartBlock(VerifyMode)
Start an expectation block with a verify mode
Public methodStartBlock(String, VerifyMode)
Start an expectation block with a label and a verify mode
Public methodStartBlockBefore(ExpectationBlock)
Start an expectation block and adds the expectations before another expectation block
Public methodStartBlockBefore(ExpectationBlock, String)
Start an expectation block with a label and adds the expectations before another expectation block
Public methodStartBlockBefore(ExpectationBlock, VerifyMode)
Start an expectation block with a verify mode and adds the expectations before another expectation block
Public methodStartBlockBefore(ExpectationBlock, String, VerifyMode)
Start an expectation block with a label and a verify mode, and adds the expectations before another expectation block
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodVerify
Verify mocked type
Public methodVerifyWithTimeout
Wait with timeout (5 seconds) for all expected methods to be called
Public methodVerifyWithTimeout(Int32)
Wait with timeout (im milliseconds) for all expected methods to be called
Top
See Also

Reference