I want to understand how to properly unit test a function such as this. The function doesn't return anything, but it does call other functions that themselves have already been unit tested. My understanding is that in order to properly unit test this method I will have to shim the dependant methods - otherwise this is just an integration test.
public void ResetColours(Colours colour)
{
var colourInfo = colour.GetInfo();
for (int i = 0; i < 9; ++i)
this.SetColourInfo(i, colourInfo);
}
I'm having a hard time deciding on the right way to shim the methods. At the moment I am thinking of doing this - shim the GetInfo method so that it returns a hard coded value, then have the SetColourInfo shim remember the information that was passed in to make sure it matches.
[TestMethod]
public void ResetColours()
{
Info[] colourInformation = new Info[9];
using (ShimsContext.Create())
{
ShimColourExtensions.GetInfoColours = (Colours colour) => new Info("test");
ShimFace.AllInstances.SetColourInfoIntInfo =
(index, colourInfo) => colourInformation[index] = true;
this.TestObject.ResetColours(Colours.Brown); //TestObject was initialized in my init method
//ASSERT that hard coded GetInfo value was set into each array index
}
}
Is this a valid unit test? Could I be doing anything better in situations like this? Should I even be writing a unit test for a method like this?