Following are the release notes for version 2.2. For obsolete APIs, see below.
|
|||||||||||||
Precompiled assemblies are now supported |
You can now mock types from predefined assemblies (except for mscorlib types). | ||||||||||||
|
|||||||||||||
Constructor argument checking |
Constructor arguments can now be validated (see Mocking Constructors). // C#
MockManager.Init (); Mock theMock = MockManager.Mock(typeof(MyClass)); // check that constructor will be called with "hello" theMock.ExpectConstructor().Args("hello"); // create the class - this will fail MyClass t = new MyClass("test"); ' Visual Basic
MockManager.Init() ' the HasStaticConstructor class is now being mocked with constructors Dim theMock As Mock = MockManager.Mock(GetType(MyClass)) ' check that constructor will be called with "hello" theMock.ExpectConstructor().Args("hello") ' create the class - this will fail Dim t As MyClass = new MyClass("test") You can use theMock.ExpectUnmockedConstructor().Args() to check the arguments but still run the real constructor code (see Verify Mode). |
||||||||||||
|
|||||||||||||
More argument checking |
All xxxAlways expectation arguments can now be validated. // C#
MockManager.Init (); Mock theMock = MockManager.Mock(typeof(MyClass)); // check that method will always be called with "hello" theMock.AlwaysReturn("method",0).Args("hello"); ' Visual Basic
MockManager.Init() ' the HasStaticConstructor class is now being mocked with constructors Dim theMock As Mock = MockManager.Mock(GetType(MyClass)) ' check that method will always be called with "hello" theMock.AlwaysReturn("method",0).Args("hello") |
||||||||||||
|
|||||||||||||
Set multiple expectation |
All expectations can now be set to one or more times. // C#
MockManager.Init (); Mock theMock = MockManager.Mock(typeof(MyClass)); // check that Log will be called twice theMock.ExpectCall("Log",2); ' Visual Basic
MockManager.Init() ' the HasStaticConstructor class is now being mocked with constructors Dim theMock As Mock = MockManager.Mock(GetType(MyClass)) ' check that Log will be called twice theMock.ExpectCall("Log",2) |
||||||||||||
|
|||||||||||||
Clearer failure messages |
Failure messages are now clearer. You can also add custom messages to built-in and custom argument checkers. // C#
// delegate method - check that parameter is larger then 4 public static bool Check(ParameterCheckerEventArgs args) { args.FailureMessage = "Custom Message"; return (int)arg.ArgumentValue > 4; } ' Visual Basic
' delegate method - check that parameter is larger then 4 Public Shared Function Check(ByVal args As ParameterCheckerEventArgs) As Boolean args.FailureMessage = "Custom Message" Check = arg.ArgumentValue > 4 End Function |
||||||||||||
|
|||||||||||||
More properties in MockManager | New properties have been added to query the MockManager state. | ||||||||||||
|
|||||||||||||
Arbitrary calls | Arbitrary calls behavior (strict) can now be defined on a per-method level (see Arbitrary Calls). | ||||||||||||
|
|||||||||||||
Call events | It is possible to receive an event each time a mocked method is called and verified. This can be set on a mock instance level or on a per-method level (see Call Events). | ||||||||||||
|
|||||||||||||
Extended Help | Help with C# and VB.NET is now included in the download. | ||||||||||||
|
|||||||||||||
Autoupdater | It is no longer needed to poll the Typemock site to know when a newer version of TypeMock is released. TypeMock will tell you. | ||||||||||||
|
|||||||||||||
Fine-tuning constructor mocking | Setting constructor expectations has been changed. MockManager.Mock(type,bool) and MockConstructor are obsolete, although they are still backward compatible. You can now use MockManager.Mock(type,Constructor) (see Mocking Constructors). MockManager.Mock(typeof(HasStaticConstructor),false); will change to MockManager.Mock(typeof(HasStaticConstructor),Constructor.NotMocked); and MockManager.Mock(typeof(HasStaticConstructor),true); will change to MockManager.Mock(typeof(HasStaticConstructor),Constructor.Mocked); |
||||||||||||
|
|||||||||||||
Verify mode has been extended | Constructors can now be verified using ExpectUnmockedConstructor(). To make the APIs more understandable, ExpectCallAndVerify has been changed to ExpectUnmockedCall. |
||||||||||||
|
|||||||||||||
Private base methods | It is now possible to mock any private methods from the full type hierarchy. | ||||||||||||
|
|||||||||||||
Obsolete APIs | Following is a list of obsolete APIs and
their new counter-APIs. Old APIs will still compile and run although a
warning will appear.
|