I have the following lambda expression showing as only partially covered in Visually Studio:
switch(elementType) {
case ParentTypes.Fire:
list = list.Where(x =>
x.Type == TypeTypes.AB ||
x.Type == TypeTypes.DE);
break;
//...
}
return list.ToList();
Everything else in the file is covered, including the case and break statements, but there is a similar section in several case statements under the same switch, all with this issue.
I have tried the list elements being of both types, and neither. The property type is Enum, with a set of possible values:
public enum TypeTypes
{
AB,
DE,
MR,
LS,
PR,
FA,
None
}
I have tried the basic (true || ??), (false || true) and (false || false) scenarios, that I have needed to use in the past. I am unsure what other scenarios the code coverage analyser is looking for? I have tried using every single enum type possible, as a test case, but the code still shows as only partially covered. Tests:
TestCase(ParentTypes.Fire, TypeTypes.AB);
TestCase(ParentTypes.Fire, TypeTypes.DE);
TestCase(ParentTypes.Fire, TypeTypes.MR, false);
TestCase(ParentTypes.Fire, TypeTypes.LS, false);
TestCase(ParentTypes.Fire, TypeTypes.PR, false);
TestCase(ParentTypes.Fire, TypeTypes.FA, false);
TestCase(ParentTypes.Fire, TypeTypes.None, false);
The second parameter simply indicates whether or not there should be any values in the list, when asserting within the test case.
What is needed to get the analyser to cover these sections of code?
Aucun commentaire:
Enregistrer un commentaire