DotNetUnitTestFreeObject Function

Action

Releases the object handle, so that the garbage collector will free the object. The object should be loaded with DotNetUnitTestLoadObject in order to work correctly.

Before the object is freed it is possible that a global CleanUp method will be called. Following unit testing frameworks support a unit-test wide CleanUp method:

  • Silk Performer .NET Framework

  • NUnit Test Framework

  • Microsoft's unit testing framework (Microsoft Visual Studio 2013、2015、2017)

During DotNetUnitTestLoadObject the information about such a method is gathered. If such a method exists, it will be called right before the object is freed.

Include file

DotNetAPI.bdh

Syntax

DotNetUnitTestFreeObject( in hObject: number,
                          in sTimer : string optional ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
hObject Handle to a .NET Object that will be released.
sTimer

(optional)

If the Unit Test class defines a global TearDown method an additional measure will be generated for this additional method call. The measure name will be {sTimer}_GlobalTearDown.

Example

dcltrans
  transaction TMain
  var
    hObject : number;
  begin
    DotNetSetOption(DOTNET_OPT_REDIRECT_CONSOLE, 1);
    hObject := DotNetUnitTestLoadObject("bin\\Release\\MyDotNet.dll", "MyDotNet.TestClass");
    DotNetUnitTestCallMethod(hObject,"TestMethod");
    DotNetUnitTestFreeObject(hObject);
  end TMain;