这是因为我试图通过以下方式对一段代码进行单元测试:
ReservationSearchParameters expectedSearchParams = new ReservationSearchParameters(), sentSearchParameters = new ReservationSearchParameters();
List<Reservation> simpleReservationList = new List<Reservation>();
simpleReservationList.Add(........... I added data ..........)
expectedSearchParams.LocationIDs = "2";
_reservationDataLayerMock.Setup(x => x.LoadReservationsByOptionalParameters(expectedSearchParams)).Returns(simpleReservationList);
sentSearchParameters.LocationIDs = "2";
Assert.AreNotEqual(null, _reservationBL.GetReservationsByOptionalParameters(sentSearchParameters).Count);
我的测试失败了,它没有返回我试图让它返回的东西,即使我的 SearchParameters 数据集是准确的,就我而言。
所以我尝试了这个:
Assert.AreEqual(expectedSearchParams, sentSearchParameters);
它失败了。为什么?