我正在对删除进行单元测试:
[Fact]
public async Task DeleteSupplierAsync_SupplierIsDeleted_WhenSupplierIsFound()
{
using (var db = new SulferFireDbContext(Utilities.TestingDbContextOptions()))
{
// Arrange
var seedSuppliers = SulferFireDbContext.GetSeedingSuppliers();
await db.AddRangeAsync(seedSuppliers);
await db.SaveChangesAsync();
var recId = 123;
var expectedSuppliers = seedSuppliers.Where(supplier => supplier.ID != recId).ToList();
// Act
await db.DeleteSupplierAsync(recId);
// Assert
var actualSuppliers = await db.Suppliers.AsNoTracking().ToListAsync();
Assert.Equal(expectedSuppliers, actualSuppliers);
}
}
问题是,expectedSuppliers
似乎actualSuppliers
是平等的,但测试失败了。这出现在Assert.Equals
我调试之后: