我有以下代码。
//I pick the first story where its StartSegment is not null.
var story = container.StorySet.FirstOrDefault(s => s.StartSegment != null);
if (story != null)
{
//the following assert fails because story.StartSegment is null.
Assert.IsNotNull(story.StartSegment,
"The target story of this homework has no start segment.");
}
此单元测试失败,因为 story.StartSegment 实际上为 null,但鉴于 FirstOrDefault lambda 表达式明确搜索起始段不为 null的故事,我认为这没有任何意义。
谁能帮我?