Using NUnit to test library with Rhinocommon

Hello all,

I am using NUnit for unit testing, but I am having trouble when I try to test objects that use Rhinocommon. I want to run rhino headless (seems like Rhino.Inside is the way to go?) so I can build this into a CICD pipeline.

I have checked out these samples online and tried to replicate how they work, but I still can’t get my tests working.
RhinoCommon Unit Testing

I made a simple dummy project to share to help figure out my issues. (attached) (2.3 MB)

It seems like StartRhino isn’t working or something has gone wrong earlier.

        [STAThread] // not sure if STAThread is required ??
        private void StartRhino()
            _rhinoCore = new Rhino.Runtime.InProcess.RhinoCore(null, 
            _running = true;

Thanks in advance for the help. I couldn’t find any recent samples, so hopefully this will be useful for others as well.

  • Jake

Hey @nacho_hero are you running windows or mac or linux?
AFAIK you can only currently unit test on Windows.

– cs

This is on windows 10 with Rhino 7 and visual studio 2022.

I’ve been writing a simpler rhino unit testing library for nunit. Here’s a sample.

public sealed class ExampleTests
	public void Brep_Translation()
		// Arrange
		var bb = new BoundingBox(new Point3d(0, 0, 0), new Point3d(100, 100, 100));
		var brep = bb.ToBrep();
		var t = Transform.Translation(new Vector3d(30, 40, 50));

		// Act

		// Assert
		Assert.AreEqual(brep.GetBoundingBox(true).Center, new Point3d(80, 90, 100));

– cs


Awesome! I will check it out, and let you know how it works.

Thank you for letting me know.

1 Like

@csykes, your library works great!

I also figured out what I was doing wrong in my project… it was silly. I was using .Net Core.

Thank you for the help! I will be using your library going forward.

  • Jake
1 Like

I’ll be updating it so it supports mac + dotnet core as soon as Rhino is updated to allow for this :slight_smile:

Please add any issues you have to the github page and I’ll fix any you find.

I’m hoping to finalise and release all the CI/CD Unit Testing libraries and environments I’ve created and record a bit of a how-to guide.

– cs