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); }
public void getBillHistoryByUserId() { string userName = "******"; List <Bill> bills = ServicesTestConstant.getBills(); _billRepository.Setup(b => b.FindAllByUserNameAndIsDeliveryPaidTrue(userName)).Returns(bills); List <BillModel> result = _billService.GetBillHistoryByUserName(userName); _billRepository.Verify(place => place.FindAllByUserNameAndIsDeliveryPaidTrue(It.IsAny <string>()), Times.Once()); Assert.AreEqual(ServicesTestConstant.getBillDto(), result[0]); Assert.AreEqual(bills.Count, result.Count); }
public void getBillsToPayByUserId() { BillInfoToPayModel billInfoToPayDto = ServicesTestConstant.getBillInfoToPayDto(); Bill bill = ServicesTestConstant.getBill(); billInfoToPayDto.LocalityGetName = bill.Delivery.Way.LocalityGet.NameEn; billInfoToPayDto.LocalitySandName = bill.Delivery.Way.LocalitySand.NameEn; List <BillInfoToPayModel> result = _billService.GetBillsToPayByUserName(ServicesTestConstant.getUserId()); _billRepository.Verify(place => place.FindAllByUserIdAndIsDeliveryPaidFalse (ServicesTestConstant.getUserId()), Times.Once()); Assert.AreEqual(ServicesTestConstant.getBills().Count, result.Count); Assert.AreEqual(billInfoToPayDto, result[0]); }
public void getBillsToPayByUserId() { Delivery setupDeliveryAndBill = EntitySetuper.SetupDeliveryAndBill(_context, false, false); BillInfoToPayModel expectedBillInfoToPayModel = new BillInfoToPayModel(setupDeliveryAndBill.Bill.BillId, setupDeliveryAndBill.Bill.CostInCents, setupDeliveryAndBill.DeliveryId, setupDeliveryAndBill.Weight, setupDeliveryAndBill.Addressee.Email); expectedBillInfoToPayModel.LocalityGetName = setupDeliveryAndBill.Way.LocalityGet.NameEn; expectedBillInfoToPayModel.LocalitySandName = setupDeliveryAndBill.Way.LocalitySand.NameEn; List <BillInfoToPayModel> result = _billService.GetBillsToPayByUserName(setupDeliveryAndBill.Bill.User.UserName); Assert.AreEqual(ServicesTestConstant.getBills().Count, result.Count); Assert.AreEqual(expectedBillInfoToPayModel, result[0]); }