0
我正在編寫一個EFException轉換器,並且正在爲它構建一個Rulset。我想驗證建設者返回的規則列表:在Nunit中,比較兩個對象列表,使它們包含相同的類型
[Test]
public void Build_CreateListOfEntityRules()
{
//arrange
var expected = new List<IEntityRule>
{
new AutomaticDataLossEntityRule(),
new CommitFailedEntityRule(),
new DbEntityValidationEntityRule(),
new DbUnexpectedValidationEntityRule(),
new DbUpdateConcurrencyEntityRule(),
new DbUpdateEntityRule(),
new EntityCommandCompliationEntityRule(),
new EntityCommandExecutionEntityRule(),
new EntityErrorEntityRule(),
new EntitySqlEntityRule(),
new InvalidOperation(),
new MigrationEntityRule(),
new MigrationsPendingEntityRule(),
new ModelValidationEntityRule(),
new ObjectNotFound(),
new PropertyConstraintEntityRule(),
new UnintentionalCodeFirstEntityRule(),
new UpdateEntityRule()
};
//act
var actual = sut.Build();
//assert
CollectionAssert.AreEquivalent(expected, actual);
}
Collection.AreEquivilent,Collection.AreEqual和Collection.Contains全部失敗;但是,當我手動查看列表的輸出時,它們是相同的。
爲什麼NUnit不認識?