Unit testing plug-in code with NUnit

Continuing the discussion from How to test at runtime if my dll is running inside Rhino or not?:

Hi menno,
Interesting way to run NUnit. I’m loading NUnit from a plug-in command and it works ok.

In my case I don’t need to have rhino running, it speeds up the test-implement cycle. We also created a plugin specific to running test code from within rhino, probably similar to what you are describing.

Sounds good. I might give that a try. I was thinking of trying resharper.

You wouldn’t absolutely need ReSharper for this; running a test assembly in the NUnit test GUI will also work if you put RhinoCommon.dll and its dependencies in the same folder. I can give you a complete list of dependencies if you want - I have to check it on Monday though.

But, that does require switching back & forth between VS and the NUnit test runner; ReSharper integration is all inside VS.

I want to try resharper anyway so I’ll go that route. Yes, if you can give me the list that would be great.
Thanks

ReSharper is a great product that is worth the investment. The refactoring stuff they have is great, and all kinds of nice keyboard shortcuts (Alt+Enter is the one I use hundreds of times a day), code style checking, LINQ suggestions, etc. etc. Takes some getting into, but I couldn’t work without it.

In C:\Program Files\Rhinoceros 5.0\System select these 9 files and copy them to the output folder where your plug-in and/or DLLs are. Note that you need to remove Rhino_DotNet and RhinoCommon prior to debugging in Rhino - otherwise your plug-in won’t load (you get an error message).

Ltdis15x.dll
Ltfil15x.dll
Ltkrn15x.dll
openNURBSx64.dll
rhcommon_c.dll
Rhino.exe
Rhino_DotNet.dll
RhinoCommon.dll
tlx64.dll

For the 32-bit version of Rhino, the files that have x64 in them, will be named differently.

1 Like

Great! I’ll give that a try. Thanks a lot.

Hi @menno, Have you managed to get this working with Rhino 6? I’ve tried copying resources to my test directory and adding Rhino System dir to my path. I’ve also tried test architecture as x64 as that worked for me in the past with Rhino 5.

The exception I’m getting is: Unable to load DLL 'rhcommon_c': A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)

I haven’t tried with Rhino6 yet, we’re planning to migrate to v6 towards the end of the year.

I’m quite sure that this method of doing unit testing is not supported by McNeel, and that the testing of more complex geometric routines will never work (and did not work in Rhino5) because of licensing issues.

Cool, thanks. I will post back here if I do figure it out.