public void confirmGettingDeliveryIsNoExistDelivery() { _deliveryRepository.Setup(s => s.FindByIdAndAddressee_IdAndIsPackageReceivedFalse( ServicesTestConstant.getUserId(), ServicesTestConstant.getDeliveryId())) .Returns((Delivery)null); var actualResult = Assert.Throws <AskedDataIsNotExist>(() => _deliveryService.ConfirmGettingDelivery( ServicesTestConstant.getUserId(), ServicesTestConstant.getDeliveryId())); Assert.AreEqual(typeof(AskedDataIsNotExist), actualResult.GetType()); }
public void confirmGettingDeliveryAllCorrect() { Delivery delivery = ServicesTestConstant.getDelivery(); _deliveryRepository.Setup(s => s.FindByIdAndAddressee_IdAndIsPackageReceivedFalse( ServicesTestConstant.getUserId(), ServicesTestConstant.getDeliveryId())) .Returns(delivery); bool result = _deliveryService.ConfirmGettingDelivery(ServicesTestConstant.getUserId(), ServicesTestConstant.getDeliveryId()); _deliveryRepository.Verify( place => place.FindByIdAndAddressee_IdAndIsPackageReceivedFalse (It.IsAny <string>(), It.IsAny <long>()), Times.Once()); _deliveryRepository.Verify( place => place.Save(), Times.Once()); Assert.IsTrue(result); Assert.IsTrue(delivery.IsPackageReceived); }