Skip to content

Test Neural Interface Manager#53

Open
fernthao wants to merge 8 commits into
release-v2.0from
test/NeuralInterfaceManager
Open

Test Neural Interface Manager#53
fernthao wants to merge 8 commits into
release-v2.0from
test/NeuralInterfaceManager

Conversation

@fernthao
Copy link
Copy Markdown

No description provided.

@fernthao fernthao force-pushed the test/NeuralInterfaceManager branch from e75769d to ccca206 Compare November 11, 2024 23:27
Copy link
Copy Markdown
Owner

@lhmcgann lhmcgann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great start! Check code coverage, also formatting. And if you could add doc-comments in the source class as well (class overall, properties, methods), that would be amazing

Assert.NotNull(result);

// That Id is stored in the out parameter
Assert.True(NIManager.IsValidResourceId(globalInterfaceId));
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Id of the neural interface itself should also be set

var result = NIManager.CreateAndRegisterNeuralInterface(interfaceType, interfaceSpecificParams, out int globalInterfaceId);

// Assert
Assert.NotNull(result);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there isn't an available Id for the interface, the method will return an empty set rather than null. In this case though, to result should specifically be the correct list of contact IDs assigned to that neural interface. You can add another parameter (or more!) to your test methods and InlineData values to take in expected values

Assert.True(NIManager.IsValidResourceId(globalInterfaceId));

// That the neural interface object created can later be looked up via the GetNeuralInterface method
Assert.True(NIManager.TryGetNeuralInterface(globalInterfaceId, out _));
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the out parameter and make sure the resource that's found is the same object as the one you gave the manager. You can use Assert.Same to check that across repeated calls to the TryGetNeuralInterface() method, the output object is the same one


// Assert
Assert.NotEmpty(contactIds);
Assert.All(contactIds, id => Assert.True(NIManager.IsValidContactId(id)));
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are good checks! Similar to comment above, can also pass in the explicit expected set of contact ids and make sure that matches too

/// <param name="interfaceType">The type of the hardware interface, for example: ContactGroup, GelPad</param>
/// <param name="interfaceSpecificParams">Parameters specific to that interface</param>
[Theory]
[InlineData(typeof(ContactGroup), new object[]{1})]
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make passing the same data into all of these methods easier, you can use the MemberData struct instead and store all the options in a single struct which you then list before each method with the [MemberData(...)] tag

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another data case to add to this MemberData item is a ContactGroup with a little more than one contact, and one with a lot more than one contact (test the integer limits!)

// Assert
Assert.Equal(numContacts, contactIds.Count);
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also may want to consider some test cases that add more than one interface to the manager at once! And test adding an interface with a single contact first followed by a multi-contact second interface, or vice versa

@lhmcgann lhmcgann removed the request for review from Blubby24 January 23, 2025 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants