Create a new Dynamic Mock Object and mock all future calls made on the mocked type.
Overload List
Name | Description | |
---|---|---|
![]() ![]() | MockObjectTMockedType |
Create an instance of TMockedType and mock calls made on the instance.
|
![]() ![]() | MockObjectTMockedType(Object) |
Create an instance of TMockedType and mock calls made on the instance, while sending constructor arguments
|
![]() ![]() | MockObjectTMockedType(Constructor) |
Create an instance of TMockedType and mock calls made on the instance, while controlling the constructor
|
![]() ![]() | MockObject(Type, Boolean) | Obsolete.
Create a new Dynamic Mock Object with ability to decide if Constructors should be mocked or not
|
![]() ![]() ![]() | MockObject(Type, Object) |
Automatically mock constructors as well, i.e. constructor code will NOT be called
|
![]() ![]() | MockObjectTMockedType(Constructor, Object) |
Create an instance of TMockedType and mock calls made on the instance, while controlling the constructor and sending constructor arguments
|
![]() ![]() | MockObject(Type, Constructor, Object) |
Create a new Dynamic Mock Object with ability to define the scope of mocked Constructors (default is to mock all constructors)
|
Remarks
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