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?



1 Like

hi @alvpickmans,

Have you tried to see some of the tests in the Dynamo and DynamoRevit project at github: https://github.com/DynamoDS/Dynamo/tree/master/test

I have learned a lot from having those two projects downloaded to my local computer so I can traverse them from inside Visual Studio

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, but I was just wondering if someone has had a similar issue and/or any reason why this might be happening.

I think is the issue here… maybe @Michael_Kirschner2 can assist

@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" ?>
    <add key="DynamoBasePath" value="C:\Program Files\Dynamo\Dynamo Core\1.3"/>
    <add key="RequestedLibraryVersion" value="Version222"/>

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.