public void getDeliveryCostAndTimeDtoAllCorrect() { Way way = EntitySetuper.SetupWayWithTarif(_context); DeliveryInfoRequestModel deliveryInfoRequestDto = new DeliveryInfoRequestModel(10, way.LocalitySandLocalityId, way.LocalityGetLocalityId); PriceAndTimeOnDeliveryModel priceAndTimeOnDeliveryModel = new PriceAndTimeOnDeliveryModel(200, 2); PriceAndTimeOnDeliveryModel result = _deliveryService.GetDeliveryCostAndTimeDto(deliveryInfoRequestDto); Assert.AreEqual(priceAndTimeOnDeliveryModel, result); }
public void getDeliveryCostAndTimeIncorrectWay() { DeliveryInfoRequestModel deliveryInfoRequestDto = getDeliveryInfoRequestDto(1); PriceAndTimeOnDeliveryModel priceAndTimeOnDeliveryDto = getPriceAndTimeOnDeliveryDto(); _wayRepository.Setup(s => s.FindByLocalitySand_IdAndLocalityGet_Id (It.IsAny <long>(), It.IsAny <long>())).Returns((Way)null); var actualResult = Assert.Throws <NoSuchWayException>(() => _deliveryService.GetDeliveryCostAndTimeDto(deliveryInfoRequestDto)); Assert.AreEqual(typeof(NoSuchWayException), actualResult.GetType()); }
public void getDeliveryCostAndTimeDtoAllCorrect() { DeliveryInfoRequestModel deliveryInfoRequestDto = getDeliveryInfoRequestDto(1); PriceAndTimeOnDeliveryModel priceAndTimeOnDeliveryDto = getPriceAndTimeOnDeliveryDto(); Delivery delivery = ServicesTestConstant.getDelivery(); Way way = delivery.Way; _wayRepository.Setup(s => s.FindByLocalitySand_IdAndLocalityGet_Id (It.IsAny <long>(), It.IsAny <long>())).Returns(way); PriceAndTimeOnDeliveryModel result = _deliveryService.GetDeliveryCostAndTimeDto(deliveryInfoRequestDto); _wayRepository.Verify( s => s.FindByLocalitySand_IdAndLocalityGet_Id (It.IsAny <long>(), It.IsAny <long>()), Times.Once()); Assert.AreEqual(priceAndTimeOnDeliveryDto, result); }
public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) { return(false); } if (ReferenceEquals(this, obj)) { return(true); } if (obj.GetType() != GetType()) { return(false); } PriceAndTimeOnDeliveryModel priceAndTimeOnDeliveryModel = (PriceAndTimeOnDeliveryModel)obj; return(CostInCents.Equals(priceAndTimeOnDeliveryModel.CostInCents) && TimeOnWayInHours.Equals(priceAndTimeOnDeliveryModel.TimeOnWayInHours)); }
protected bool Equals(PriceAndTimeOnDeliveryModel other) { return(CostInCents == other.CostInCents && TimeOnWayInHours == other.TimeOnWayInHours); }