I am trying to write a unit test to compare actual results to expected results, where the class I am testing gives me a IReadOnlyCollection and my expected results are List.
I read over the this answer about comparing Lists using CollectionAssert at How to compare Lists in Unit Testing, however when I attempt to do so, I get compiler error "cannot convert from 'System.Collections.Generic.IReadOnlyCollection' to 'System.Collections.ICollection'"
Here is my test method:
[TestMethod]
public void EveningMotion()
{
IDateTimeProvider dateTimeProvider = new MockDateTimeProvider(new DateTime(2018, 1, 1, 20, 0, 0));
ILightHardwareInterface frontyardLights = new MockLightHardwareInterface();
MockLightHardwareInterface backyardLights = new MockLightHardwareInterface();
LightController controller = new LightController(dateTimeProvider, frontyardLights, backyardLights);
controller.ActuateLights(true);
IReadOnlyCollection<bool> actualResult = backyardLights.GetRecording();
List<bool> expectedResult = new List<bool>
{
true
};
CollectionAssert.AreEqual(expectedResult, actualResult);
}
What is one to do? I kind of want to keep the expected and actual results comparison rather than iterating through both element by element, if possible.