示例#1
0
        public void SetupBeforeEachTest()
        {
            _billRepository     = new Mock <IBillRepository>();
            _userRepository     = new Mock <IUserRepository>();
            _deliveryRepository = new Mock <IDeliveryRepository>();
            _wayRepository      = new Mock <IWayRepository>();

            _billRepository.Setup(a => a.FindByIdAndIsDeliveryPaidFalse(ServicesTestConstant.getBillId()))
            .Returns(ServicesTestConstant.getBill());
            _billRepository.Setup(a => a.FindAllByUserIdAndIsDeliveryPaidFalse(It.IsAny <string>()))
            .Returns(ServicesTestConstant.getBills());

            _userRepository.Setup(a => a.FindByIdAndUserMoneyInCentsGreaterThanEqual
                                      (ServicesTestConstant.getUserId(), ServicesTestConstant.getBill().CostInCents)
                                  ).Returns(ServicesTestConstant.getAddreser());

            _userRepository.Setup(a => a.FindByEmail(It.IsAny <string>())
                                  ).Returns(ServicesTestConstant.getAdversee());
            _userRepository.Setup(a => a.FindByName(It.IsAny <string>())
                                  ).Returns(ServicesTestConstant.getAdversee());

            _wayRepository.Setup(a => a.FindByLocalitySand_IdAndLocalityGet_Id
                                     (It.IsAny <long>(), It.IsAny <long>())
                                 ).Returns(ServicesTestConstant.getWay());
            _billService = new BillService
                               (_billRepository.Object, _userRepository.Object, _deliveryRepository.Object, _wayRepository.Object);
        }
示例#2
0
        public void initializeBillCorrect()
        {
            Bill bill = ServicesTestConstant.getBill();

            bill.CostInCents    = _defaultCostInCents;
            bill.BillId         = _defaultBillId;
            bill.IsDeliveryPaid = false;
            Delivery delivery = ServicesTestConstant.getDelivery();

            delivery.DeliveryId = _defaultDeliveryId;
            _wayRepository.Setup(a => a.FindByLocalitySand_IdAndLocalityGet_Id
                                     (It.IsAny <long>(), It.IsAny <long>())
                                 ).Returns(ServicesTestConstant.getWay());

            Bill billResult = _billService.InitializeBill(ServicesTestConstant.getDeliveryOrderCreateDto(),
                                                          ServicesTestConstant.getUserId());

            Assert.AreEqual(bill, billResult);
        }