【发布时间】:2016-10-07 10:19:23
【问题描述】:
我有一本字典,其中包含来自已解析测试运行的信息。键是方法的名称,值是TestRunProperties 的列表。我的字典包含来自测试运行的所有方法,我想删除在测试运行期间失败的方法。这可能与Linq有关吗?
TestRunProperties 类:
public class TestRunProperties
{
public string computerName { get; set; }
public TimeSpan duration { get; set; }
public string startTime { get; set; }
public string endTime { get; set; }
public string testName { get; set; }
public string outcome { get; set; }
}
字典:
//Key is the name of the method, value is the properties associated with each run
private static Dictionary<string, List<TestRunProperties>> runResults = new Dictionary<string, List<TestRunProperties>>();
我已经尝试过了,但我认为我对 Where 部分感到困惑:
runResults.Remove(runResults.Where(methodName => methodName.Value.Where(method => method.outcome.ToLower().Equals("failed"))));
我对 Linq 和 Lambda 还很陌生,我仍在尝试了解如何访问这样的数据。
【问题讨论】:
-
感谢大家的帮助,所有的答案都非常棒!
标签: c# linq dictionary lambda