Get a query from an assembly


If you want to test a Data Access Layer there is a high probability that queries are generated by .Net code contained in an assembly. NBi is able to perform a call to a method in an assembly and interpret the result (a string or a command (sql, adomd or oledb)) as the query to test.

This feature offers the opportunity to test a query generated by a dll compiled in .Net and assert the syntax but also the result-set after execution or the performance.

You need to define a system-under-test and inside the execution element, you’ll need to define from which method in which assembly you want to retrieve the query. This is done by specifying the path to your assembly, the class and the method (attributes).

<system-under-test>
  <result-set>
    <assembly
      path="NBi.Testing.dll"
      class="NBi.Testing.Acceptance.Resources.AssemblyClass"
      method="GetSelectMdx"
    />
  </result-set>
</system-under-test>

Parameters

If your method is expecting some parameters you can specify them in your test. To achieve this, specify an element parameter and the attribute name filled with the name of the parameter in your method. The value that you want to pass is specified in the xml element. Here we’re providing a .net parameter named calendarYear with the value CY 2004

<system-under-test>
  <result-set>
    <assembly
      path="NBi.Testing.dll"
      class="NBi.Testing.Acceptance.Resources.AssemblyClass"
    me  thod="GetSelectMdx"
    />
      <parameter name="calendarYear">CY 2004</parameter>
    </assembly>
  </result-set>
</system-under-test>

It’s possible to pass value for parameters of type string, any numerical type, enum and DateTime. If you want to pass a DateTime the value must be provided under the format YYYY-MM-DD or YYYY-MM-DD HH:mm. For an enum, just specify the string representation of the value for the enum (expl: Blue or MatchingCase).

Static method

If your method is static, you need to inform NBi by specifying the xml attribute isStatic and set its value to true.