Unit Test GeometricTestBase Failing when geometry is created

I am trying to implement unit tests using the geometry library, following all steps as indicated in https://github.com/DynamoDS/Dynamo/wiki/Writing-Unit-Test-Libraries-for-Dynamo.
The TestService.dll library gets loaded appropriately, but tests fail throwing an exception if any geometry object is created during the test:

Result StackTrace:	
at Autodesk.DesignScript.Geometry.HostFactory.get_Factory()
at Autodesk.DesignScript.Geometry.Point.ByCoordinates(Double x, Double y, Double z)
at Tests.HelloWorldTests.FailingTest() in C:\Users\****\HelloWorldTest.cs:line 27
Result Message:	System.NotImplementedException : Exception has been thrown by the target of an invocation.

Has anyone had this issue before? Any hints on how to solve it?

Thanks!
Alvaro

@erfajo

1 Like

Hi @erfajo, I am quite familiar with the projects including DynamoSample, where there is a simple implementation of unit testing with GeometricBaseTest (it is actually almost the same code as the one I posted).

I agree with you that it is very helpful to have them locally and inspect them, but from the stacktrace error it seems that it has something to do with the geometry library.

It might have something to do with my Dynamo install, version 1.3.0.875, but I was just wondering if someone has had a similar issue and/or any reason why this might be happening.

@alvpickmans what does your testServices.dll.config file look like? That sample might be a bit out of date I would try 222 - 224 for library version.

also - I have not tested this in a while but I might be useful as an alternative testing method:

@Michael_Kirschner2 I have tried with 220 to 222 with the same result:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="DynamoBasePath" value="C:\Program Files\Dynamo\Dynamo Core\1.3"/>
    <add key="RequestedLibraryVersion" value="Version222"/>
  </appSettings>
</configuration>

It seems to be loading properly, but throwing an exception only when starting HostFactory.
I will try to test on a different version of Dynamo and/or build it and try again.

I am having the same issue. Has a solution been found?

Error Message:
System.NotImplementedException : Exception has been thrown by the target of an invocation.
Stack Trace:
at Autodesk.DesignScript.Geometry.HostFactory.get_Factory()
at Autodesk.DesignScript.Geometry.Point.ByCoordinates(Double x, Double y, Double z)

No that I know of, on another project I ended up copying (using a csproj Target task) the whole Dynamo Runtime Folder to the $(OutDir) so base test class could find required files

<PropertyGroup>
    <!--
     In order to run DynamoTest, the test .dll must be deployed to a directory
     containing the complete Dynamo Runtime
    -->
    <DynamoRuntimeDirectory>C:\Program Files\Dynamo\Dynamo Core\2.6\</DynamoRuntimeDirectory>
  </PropertyGroup>
  <Target Name="CopyDynamoRuntime" AfterTargets="AfterBuild" Condition="Exists($(DynamoRuntimeDirectory)) != '' And Exists($(DynamoRuntimeDirectory))">
    <PropertyGroup>
      <!--Files to exclude from Dynamo Runtime folder due to version conflicts-->
      <ExcludeFiles>
        $(DynamoRuntimeDirectory)\**\*Restsharp.*;
        $(DynamoRuntimeDirectory)\**\*Newtonsoft.Json.*
      </ExcludeFiles>
    </PropertyGroup>
    <ItemGroup>
      <DynamoRuntime Include="$(DynamoRuntimeDirectory)\**\*" Exclude="$(ExcludeFiles)" />
    </ItemGroup>

    <!-- Copy newly compiled add-in files to AppData folder (before starting the debugger) -->
    <Message Importance="high" Text="Copying Dynamo Runtime from $(DynamoRuntimeDirectory) to folder $(OutDir)" />

    <Copy SourceFiles="@(DynamoRuntime)" DestinationFolder="$(OutDir)%(RecursiveDir)" SkipUnchangedFiles="true" OverwriteReadOnlyFiles="true" Retries="3" RetryDelayMilliseconds="300" />

  </Target>