Problem with unit testing of GH components using Xunit and Rhino.Inside

Hello forum,

I am currently working on creating unit testings for customed grasshopper components by following the examples here

The examples from rhino developer samples use XUnit, Rhino.inside and some other packages. The example tests open the gh files, feed inputs into components, and then compare the components’ outputs to the expected values.

I changed a bit the examples to test our gh components, it works quite okay with opening the gh file and finding the correct component to test. The problem I am facing now is to set the correct inputs of the components, force the component to recompute and collect data.

Below is the code I used to set the input, where the index is usually zero and the spaces is a list of objects:

 var input = new Param_GenericObject();
 input.CreateAttributes();
 input.Access = GH_ParamAccess.list;
 foreach (Space space in spaces)
     input.PersistentData.Append(new GH_ObjectWrapper(space));
 component.Params.Input[index].AddSource(input);

The code I used to resolve the instance and get the output:

// Recompute and get data
component.ExpireSolution(true);
component.CollectData();
component.ComputeData();

// Extract the output data 
List<Parameter> ParameterObjects = new List<Parameter>();
var test = component.Params.Output[0].VolatileData.get_Branch(0))

Somehow the input of the components is not always correctly set, and even if it is correctly set, the component does not recompute (as least from what I see) when I use the ExpireSolution, CollectData and ComputeData methods, so in the VloatieData of the output, it is always empty data.

Do you maybe have some ideas on why this is happening and how to solve these issues? If you have ideas about how to do unit testings for customed grasshopper component, it is also welcomed. Thanks in advance!

@Bill_Cook I followed the samples mentioned in this post https://discourse.mcneel.com/t/unit-testing-c-project/147011. And the sample codes from here https://github.com/mcneel/rhino-developer-samples/tree/7/rhino.inside/dotnet/SampleUnitTests. I know the content mentioned here is not the most relevant because it is about the inputs and outputs, but could you maybe take a look or tag someone who you think might know the answer? Thanks!