Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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());
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
 protected bool Equals(PriceAndTimeOnDeliveryModel other)
 {
     return(CostInCents == other.CostInCents && TimeOnWayInHours == other.TimeOnWayInHours);
 }