MockManager.MockObject Method

Typemock Isolator Developer Guide
Create a new Dynamic Mock Object and mock all future calls made on the mocked type.
Overload List

  NameDescription
Public methodStatic memberMockObject<TMockedType>()
Create an instance of TMockedType and mock calls made on the instance.
Public methodStatic memberMockObject<TMockedType>(Object[])
Create an instance of TMockedType and mock calls made on the instance, while sending constructor arguments
Public methodStatic memberMockObject<TMockedType>(Constructor)
Create an instance of TMockedType and mock calls made on the instance, while controlling the constructor
Public methodStatic memberMockObject(Type, Boolean) Obsolete.
Create a new Dynamic Mock Object with ability to decide if Constructors should be mocked or not
Public methodStatic memberCode exampleMockObject(Type,Object[])
Automatically mock constructors as well, i.e. constructor code will NOT be called
Public methodStatic memberMockObject<TMockedType>(Constructor,Object[])
Create an instance of TMockedType and mock calls made on the instance, while controlling the constructor and sending constructor arguments
Public methodStatic memberMockObject(Type, Constructor,Object[])
Create a new Dynamic Mock Object with ability to define the scope of mocked Constructors (default is to mock all constructors)
Top
Remarks

Example of using Typemock Isolator to create a mock object for IList
Examples

[Test]
   public void ValidateValidUser()
       {
       //Create new Mock Object for IList, all calls to this class, are 
       //intercepted.
       MockObject mock = MockManager.MockObject(typeof(IList));

       // We expect that the Count parameter will be called (once) and we will return 4
       mock.ExpectGet("Count", 4);
    // Get our mocked OBJECT
       IList list = mock.Object as IList;

       // lets just run it, normally the Object will be passes as a parameter to a tested class
       Assert.AreEqual(4, list.Count);

       // Verify that all the expected calls have actually been called.
       MockManager.Verify();
}
See Also

Reference