Loads a .NET Assembly and creates an instance of a .NET type. A handle to this created object will be returned.
When creating the object, the default constructor will be called. If you want to call a constructor that takes parameters you have to set these parameters with the DotNetSetXX functions prior to the call to DotNetLoadObject.
The difference to DotNetLoadObject is that this method checks whether the instantiated type is unit test conform. Currently - 3 unit testing frameworks are supported:
Silk Performer .NET Framework
NUnit Test Framework
Microsoft's unit testing framework (Microsoft Visual Studio 2013、2015、2017)
The method inspects the type for the custom attributes of the above mentioned test frameworks. If the class defines a method that should be called once the class is loaded - the method will be called right after it is instantiated. If there is a corresponding cleanup method - the cleanup method will be called when the object is unloaded with DotNetUnitTestFreeObject.
Initialize (SetUp) and CleanUp (TearDown) methods will be called by DotNetUnitTestCallMethod.
It is recommended to redirect the console output to Silk Performer logfile's. This should be done because above mentioned test framework do it as well. Redirection can be enabled by the new option DOTNET_OPT_REDIRECT_CONSOLE which can be set with DotNetSetOption.
DotNetAPI.bdh
DotNetUnitTestLoadObject( inout sAssemblyFile : string, inout sTypeName : string, in sTimer : string optional ): number;
object handle if successful
0 otherwise
Parameter | Description |
---|---|
sAssemblyFile | Path to the assembly file that contains the specified type. The path can be either absolute or relative. If the path is relative, it is either relative to the project or the data directory. |
sTypeName | Full qualified type name (Namespace + TypeName) of the type that should be instantiated. |
sTimer |
(optional) If defined – a custom timer will be generated to measure the creation time of the object. If the Unit Test class defines a global SetUp method an additional measure will be generated for this additional method call. The measure name will be {sTimer}_GlobalSetUp. |
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;