我有一个验证方法的收集输出的测试。测试的这种变体通过:
[TestMethod, TestCategory("BVT")]
public void TheStatusesAreReturned()
{
var expectedUnprocessedStatuses = new List<FileUploadStatus>
{
FileUploadStatus.InProcess,
FileUploadStatus.Pending,
};
Sut.GetUnprocessedStatuses()
.Should()
.BeEquivalentTo(expectedUnprocessedStatuses);
}
这种测试变体失败,出现错误“Expected item[0] to be InProcess, but found Pending”:
[TestMethod, TestCategory("BVT")]
public void TheStatusesAreReturned2()
{
var expectedUnprocessedStatuses = new List<FileUploadStatus>
{
FileUploadStatus.InProcess,
FileUploadStatus.Pending,
};
Sut.GetUnprocessedStatuses()
.ShouldBeEquivalentTo(expectedUnprocessedStatuses);
}
显然,ShouldBeEquivalentTo
关心收集项目的顺序,而不关心BeEquivalentTo
。为什么这两种方法的等效概念不同?