Rhino3dm userData in rhino Test Project undefined for some team members

I have a project I’ve built using the new Rhino.Testing beta
and I have a test loading user data from our plugin
using a 3dm file I’ve persisted

I’m on Rhino version 8.11
the tests pass on my machine…

but not on the machine of my teammates
we have the same rhino version, we’re on the same file versions
the files open as expected when opened directly
but fail to load the user data in the tests on their machines

I’m not sure what could be wrong

1 Like

Userdata can be interpreted only by the plug-in that wrote the data, assuming you’re talking about custom userdata. Make sure that all your team members have the plug-in also installed.

I was talking about custom user data,
the confusing thing is that they can open the files and the user data loads, it just doesn’t find the user data in the tests

@CallumSykes can you help here?

Hey @Christina3 do you have some code you can share so I can try to replicate? If you can’t share here I’m happy if you want to DM me some code. We can see if the tests fail on mine, and if so, why :slight_smile:

Hello @CallumSykes

my tests are pretty simple
I have a separate TestUtility Project to define my test Fixture

<Project Sdk="Microsoft.NET.Sdk">
	<PropertyGroup>
		<TargetFramework>net7.0-windows</TargetFramework>
		<IsPackable>false</IsPackable>
	</PropertyGroup>

	<ItemGroup>
		<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.*" />
		<PackageReference Include="NUnit" Version="3.*" />
		<PackageReference Include="NUnit3TestAdapter" Version="4.*" />
		<PackageReference Include="Rhino.Testing" Version="8.0.16-beta" />
		<PackageReference Include="RhinoCommon" Version="8.4.24044.15001" />
	</ItemGroup>
</Project>

that’s my project file

using Microsoft.Win32;
using NUnit.Framework;
using Rhino.Testing.Fixtures;
using System.IO;

namespace TestUtility
{
    [SetUpFixture]
    public class SetupFixture : RhinoSetupFixture
    {
        public override void OneTimeSetup()
        {
            var rhinoDir = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\McNeel\Rhinoceros\8.0\Install", "Path", null) as string ?? string.Empty;
            Assert.True(Directory.Exists(rhinoDir), string.Format("Rhino system dir not found: {0}", rhinoDir));

            var xml = $@"<?xml version=""1.0"" encoding=""utf-8""?>
<Settings>
	<RhinoSystemDirectory>{rhinoDir}</RhinoSystemDirectory>
</Settings>
";
            File.WriteAllText("Rhino.Testing.Configs.xml", xml);
            base.OneTimeSetup();
        }

        public override void OneTimeTearDown()
        {
            base.OneTimeTearDown();
        }
    }
}

and that’s the setup fixture

as for the failing test itself
I create a headless rhino document to get my testing data

private IEnumerable<GeometryBase> GetGeometryListFrom5CirclesTestFile()
{
    var testDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
        "..\\..\\..\\Data\\5CirclesOneSquareAddedToRecipe.3dm");
    return RhinoDoc.CreateHeadless(testDirectory).Objects.Select(rObj => rObj.Geometry);
}

and in code I try to load my geometries by filtering out the UserData

var userDataGeometries = geometries.Where(g => g.HasUserData);
return userDataGeometries
    .Where(g => g.UserData.Any(userData => userData.ToString().Contains(nameof(UserDataTypes.StepUserData)))).ToList()

for my teammates the user data is null, but just for the testing
the same mechanism is used when opening the file manually, and that works for them

Could you include a version of 5CirclesOneSquareAddedToRecipe.3dm that has some data in it for me? :slight_smile:

5CirclesOneSquareAddedToRecipe.3dm (49.4 KB)
here’s the test file I was using

Coming back to this, I think it may have had something to do with an invalid Plugin instance?
I was able to recreate the issue, and then solve it by building, opening and saving the file before running the test again

Let me know if that isn’t the solution in the end, it sounds quite plausible to me.

In your SetUpFixture,

You cannot create the “Rhino.Testing.Configs.xml” at the runtime, this because this file won’t be consumed by Rhino’s setup routine. It is too late when you create the config.xml in this OneTimeSetup(). You have to manually create it first and include it in the compiled folder.