Release Notes

Version 4.2

To view breaking changes, see below.

These are the release notes for Release 4.2.

This is the last Isolator version to support CLR 1.1/VS 2003. The next version will support CLR 2.0 and above. 

 


Field mocking 

Typemock Isolator supports mocking fields that are class type (fields that are struct types or value types are not mocked)

Enterprise Edition Only (see Typemock Isolator Editions)
Typemock Isolator supports mocking field members that are class type. Using field mocking users can mock calls made on internal fields inside other mocked objects. Users can also assign values to the mock, which will be set later to the instance created. The following example shows how to mock a field using both natural and reflective APIs (for further information, see Mocking Fields and Mocking Fields - Natural).

Mocking fields with Natural Mocks:

// C#
// Field 

/// <summary>
/// Class that has another class as a public field
/// </summary>

public class ClassWithField
{
    public FieldClass field;

}

/// <summary>
/// class which reside as a field.
/// </summary>

public class FieldClass
{
    /// <summary>
    /// will always return 5 (unless mocked)
    /// </summary>
    /// <returns>5</returns>

    public int ReturnFive()
    {
        return 5;
    }
}

[Test]
[VerifyMocks]
public void MockInstanceField()
{
    using (RecordExpectations recorder = RecorderManager.StartRecording())
    {
        //CAUTION: ALL calls here are mocked!!!
        //mock next instance creation of ClassWithField
        //ctor will be mocked so "field" will not initialize

        ClassWithField mock = new ClassWithField();
        int dummy = mock.field.ReturnFive();
        recorder.Return(6);
    }

    ClassWithField target = new ClassWithField();
    int actual = target.field.ReturnFive();
    //ReturnFive call is mocked and should return 6
    Assert.AreEqual(6, actual);

*This feature is causing a change in Natural Mocks behavior - see breaking changes 
Mocking Fields using Reflective Mocks:

[Test]
[VerifyMocks]
public void MockInstanceField()
{
    // mock next instance creation of ClassWithField
    Mock mock = MockManager.Mock<ClassWithField>();
    // mock the "field" field and set the expectation on it
    Mock mockedField = mock.MockField("field");
    mockedField.ExpectAndReturn("ReturnFive", 6);

    ClassWithField target = new ClassWithField();
    int actual = target.field.ReturnFive();
    // ReturnFive call is mocked and should return 6
    Assert.AreEqual(6, actual);



Debugger Integration

Enterprise Edition Only (see Typemock Isolator Editions)

  • When you step in the debugger into a mocked method, the mocked method will be painted

  • The debugger can be run inside a recording block without confusing the test
  • A debugger evaluation tool can be invoked without changing the rest of the test behavior;  when evaluating a mocked method, the fake return value will be given but the actual call is ignored by the mocking framework

Typemock Isolator examples

  • Examples using MSTest framework were added
  • VB examples for mocking a new .NET 3.5 syntax have been added

DotTrace 3.0

Professional Edition Only (see Typemock Isolator Editions)

The new release of DotTrace profiler (3.0) is now supported and can be linked to run with Typemock Isolator


Final builder

Professional Edition Only (see Typemock Isolator Editions)

Typemock Isolator Task for running test with mocking enabled was created for the Final Builder Tool.


General enhancements

  • A generic API for creating mocks is now available in the Community edition


Performance The major performance degradation when using .NET 1.1 with Typemock Isolator Version 4.X was found and fixed

General fixes
  • Exception type is now passed correctly to the application
  • Dont Clear behaves correctly on objects created using the RecorderManager.CreateMockedObject API (Dont Clear applies only to objects created after it was declared)
  • Typemock Isolator can now handle partial trusted assemblies
  • Generic structures can now be used as fake return objects
  • Use of ref/out parameters is again a community feature
  • When using VerifyMock decorator, verification is also done if the test throws an expected exception
  • Fixed a bug that causes VSTestHost of VS2008 on 64 bit machines to crash when running  tests.
  • �Invalid Operation Exception� when working with NHybernate and XML serialization was fixed.
  • Complex LINQ queries are now mocked correctly.
  • Manual assembly loading does not cause an exception. AssemblyResolve event fires correctly.
  • RepeatAlways now works correctly following WhenArgumentsMatch.
  • Returning values of types that inherit from generic type now work correctly.
  • GetMocks return the correct mocks for abstract classes and interfaces.
  • Following undeploy Typemock Isolator remains registered.
  • Methods up to 30 parameters can now be mocked.

Installation defect fixes Visual studio 2005 Add-In is now properly removed when uninstalling Typemock Isolator


Natural Mocks
  • Extension method on MSCorlib classes can now be mocked inside a chained statement
  • The mechanism for recognizing chained statement has been improved to recognize only calls made on the same line (note that the "new" operation cannot be chained)
  • OnAssemblyLoad calls for VJSClassLoader made during a recording block are now ignored

Events
  • Events declared on abstract classes can now be mocked
  • Events declared in derived interfaces can now be mocked


Breaking changes
  • The Repeat and RepeatAlways API is applied to the entire chain and not just to the last call; for specifics, see Repeat With Natural
  • By default, constructors calls are mocked also on objects created using the generic API; see First Mock Using Generic Helper for more details
  • Fast mode has been disabled
  • Using Natural Mocks syntax will now automatically add mocks on all fields (both static and instance) of objects being mocked. This may cause some issues if part of the application logic is based upon fields value being null. check Fields mocking - Natural for more details.
  • The API ValidateArgsOnVerify is now obsolete. If arguments do not match, an exception is thrown both on the check itself, and also on Verify.


 

Copyright © Typemock Ltd. 2004-2020. All Rights Reserved.