Overwriting TestStepRun.Parameters in subclass causes errors
After overwriting TestStepRun.Parameters, calling TestStepRun.Verdict will throw an exception due to an assumption made of which index Verdict will have inside parameters.
Try the following:
class MockPlanRun : TestPlanRun
{
public MockPlanRun( TestPlan plan, IList<IResultListener> resultListeners, DateTime startTime, long startTimeStamp, bool isCompositeRun = false) : base(plan, resultListeners, startTime, startTimeStamp, isCompositeRun)
{
throw new Exception();
}
public MockPlanRun(Guid id, TestPlanRun baseRun)
: base(new TestPlan(), Array.Empty<IResultListener>(), baseRun.StartTime, baseRun.StartTimeStamp, baseRun.TestPlanXml)
{
foreach (var elem in baseRun.Parameters)
{
Parameters[elem.Name, elem.Group] = elem.Value;
}
Id = id;
}
}
class MockStepRun : TestStepRun
{
public MockStepRun(Guid parent, Guid id, TestStepRun baseRun) : base(new LogStep(), parent)
{
this.Id = id;
Parameters = baseRun.Parameters; // this does not work
// on the other hand, this works:
//foreach (var elem in baseRun.Parameters)
//{
// Parameters[elem.Name, elem.Group] = elem.Value;
//}
}
}
Edited by Rolf Madsen