Forum Discussion

bill's avatar
bill
Occasional Contributor
10 years ago
Solved

Creating .Net enumerations from Test Complete?

Maybe I'm just overthinking this, but I didn't see any documentation about how to create an enumeration type to pass to a .Net method.



I'm trying to call a method on the Syncfusion Grid Grouping Control via something like this:



                var net = Process("Blah").AppDomain("Blah.exe").dotNET;


                var enumType =

                         net.Syncfusion_Windows_Forms_Grid_GridRangeOptions.GetType();


                var rangeInfoOptions = net.System_Enum.Parse(

                         enumType,

                         "MergeCoveredCells,MergeFloatedCells");




However, I recieve the dreaded "'Syncfusion_Windows_Forms_Grid_GridRangeOptions' is null or not an object" error from Test Complete.



I could use the global dotNET object with the CLR Bridge option but I'm not sure what that means about having to have the necessary assembly around at run time.

(and the assembly version in CLR bridge might not match the version the app domain is using) :(



I'm sure I'm forgetting something unbelievably silly, but thanks a bunch if you have any suggestions for this issue.



Thanks again,

Bill



 

  • Hi Bill,



    First, change:



    Syncfusion_Windows_Forms_Grid_GridRangeOptions => Syncfusion_Windows_Forms_Grid.GridRangeOptions

    System_Enum => System.Enum



    Note the period before the class name. The syntax is:

    namespace_with_underscores.class


    For example:

    Namespace: Syncfusion.Windows.Forms.Grid

    Class: GridRangeOptions

    TestComplete syntax: dotNET.Syncfusion_Windows_Forms_Grid.GridRangeOptions



    When in doubt, check Code Completion.



    I don't have your assembly to check, but this works for a built-in .NET enum:

    var enumType = dotNET.System_IO.FileOptions.Asynchronous.GetType();

    var options = dotNET.System.Enum.Parse(enumType, "Asynchronous,DeleteOnClose");

    Log.Message(options);


    So in your case, it should be something like this:

    var net = Process("Blah").AppDomain("Blah.exe").dotNET;

    var enumType = net.Syncfusion_Windows_Forms_Grid.GridRangeOptions.MergeCoveredCells.GetType();

    var rangeInfoOptions = net.System.Enum.Parse(enumType, "MergeCoveredCells,MergeFloatedCells");

2 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Bill,



    First, change:



    Syncfusion_Windows_Forms_Grid_GridRangeOptions => Syncfusion_Windows_Forms_Grid.GridRangeOptions

    System_Enum => System.Enum



    Note the period before the class name. The syntax is:

    namespace_with_underscores.class


    For example:

    Namespace: Syncfusion.Windows.Forms.Grid

    Class: GridRangeOptions

    TestComplete syntax: dotNET.Syncfusion_Windows_Forms_Grid.GridRangeOptions



    When in doubt, check Code Completion.



    I don't have your assembly to check, but this works for a built-in .NET enum:

    var enumType = dotNET.System_IO.FileOptions.Asynchronous.GetType();

    var options = dotNET.System.Enum.Parse(enumType, "Asynchronous,DeleteOnClose");

    Log.Message(options);


    So in your case, it should be something like this:

    var net = Process("Blah").AppDomain("Blah.exe").dotNET;

    var enumType = net.Syncfusion_Windows_Forms_Grid.GridRangeOptions.MergeCoveredCells.GetType();

    var rangeInfoOptions = net.System.Enum.Parse(enumType, "MergeCoveredCells,MergeFloatedCells");
  • bill's avatar
    bill
    Occasional Contributor
    That did the trick. I knew it was something simple but I had been staring at too much documentation on Friday. (Test Complete's, and the Syncfusion docs for the Grid Grouping Control).



    Thanks!



    Bill