public void confirmGettingDeliveryAllCorrect() { Delivery delivery = EntitySetuper.SetupDeliveryAndBill(_context, false, true); bool result = _deliveryService.ConfirmGettingDelivery(delivery.Addressee.UserName, delivery.DeliveryId); Assert.IsTrue(result); Assert.IsTrue(delivery.IsPackageReceived); }
public void payForDeliveryDeliveryAlreadyPaid() { Delivery setupDeliveryAndBill = EntitySetuper.SetupDeliveryAndBill(_context, false, true); var actualResult = Assert.Throws <DeliveryAlreadyPaidException>(() => _billService.PayForDelivery (ServicesTestConstant.getUserId(), ServicesTestConstant.getBillId())); Assert.AreEqual(typeof(DeliveryAlreadyPaidException), actualResult.GetType()); }
public void payForDeliveryWhenAllCorrect() { Delivery setupDeliveryAndBill = EntitySetuper.SetupDeliveryAndBill(_context, false, false); bool payResult = _billService.PayForDelivery(setupDeliveryAndBill.Bill.User.Email, setupDeliveryAndBill.Bill.BillId); Assert.IsTrue(payResult); Assert.IsTrue(setupDeliveryAndBill.Bill.IsDeliveryPaid); }
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 confirmGettingDeliveryIsNoExistDelivery() { User adresee = EntitySetuper.SetupAdresee(_context); long randomNotExsistDeliveryId = 100L; var actualResult = Assert.Throws <AskedDataIsNotExist>(() => _deliveryService.ConfirmGettingDelivery( adresee.UserName, randomNotExsistDeliveryId)); Assert.AreEqual(typeof(AskedDataIsNotExist), actualResult.GetType()); }
public void GetLocalities() { Way way = EntitySetuper.SetupWayWithTarif(_context); LocalityModel expectedGet = new LocalityModel(way.LocalityGetLocalityId, way.LocalityGet.NameEn); LocalityModel expectedSend = new LocalityModel(way.LocalitySandLocalityId, way.LocalitySand.NameEn); List <LocalityModel> result = _localityService.GetLocalities(); Assert.AreEqual(expectedSend, result[0]); Assert.AreEqual(expectedGet, result[1]); Assert.AreEqual(2, result.Count); }
public void getBillHistoryByUserId() { Delivery setupDeliveryAndBill = EntitySetuper.SetupDeliveryAndBill(_context, false, true); List <BillModel> result = _billService.GetBillHistoryByUserName(setupDeliveryAndBill.Bill.User.UserName); Assert.AreEqual(setupDeliveryAndBill.DeliveryId, result[0].DeliveryId); Assert.AreEqual(setupDeliveryAndBill.Bill.BillId, result[0].Id); Assert.True(result[0].IsDeliveryPaid); Assert.AreEqual(EntitySetuper.BILL_COST, result[0].CostInCents); Assert.AreEqual(1, result.Count); }
public void getDeliveryCostAndTimeIncorrectWay() { Way way = EntitySetuper.SetupWayWithTarif(_context); int notExistLocalitySend = 300; DeliveryInfoRequestModel deliveryInfoRequestDto = new DeliveryInfoRequestModel(10, notExistLocalitySend, way.LocalityGetLocalityId); var actualResult = Assert.Throws <NoSuchWayException>(() => _deliveryService.GetDeliveryCostAndTimeDto(deliveryInfoRequestDto)); Assert.AreEqual(typeof(NoSuchWayException), actualResult.GetType()); }
public void GetDeliveryInfoToGet() { Delivery delivery = EntitySetuper.SetupDeliveryAndBill(_context, false, true); DeliveryInfoToGetDto deliveryInfoToGetDto = ServicesTestConstant.getDeliveryInfoToGetDto(); deliveryInfoToGetDto.LocalityGetName = delivery.Way.LocalityGet.NameEn; deliveryInfoToGetDto.LocalitySandName = delivery.Way.LocalitySand.NameEn; List <DeliveryInfoToGetDto> result = _deliveryService.GetDeliveryInfoToGet(delivery.Addressee.UserName); Assert.AreEqual(deliveryInfoToGetDto, result[0]); Assert.AreEqual(ServicesTestConstant.getDeliveres().Count, result.Count); }
public void payForDeliveryNotEnoughMoney() { Delivery setupDeliveryAndBill = EntitySetuper.SetupDeliveryAndBill(_context, false, false); setupDeliveryAndBill.Bill.User.UserMoneyInCents = 0; _context.SaveChanges(); var actualResult = Assert.Throws <NotEnoughMoneyException> (() => _billService.PayForDelivery(ServicesTestConstant.getUserId(), ServicesTestConstant.getBillId())); Assert.AreEqual(typeof(NotEnoughMoneyException), actualResult.GetType()); }
public void getDeliveryCostAndTimeIncorrectWeightFactorBiggerOnOne() { Way way = EntitySetuper.SetupWayWithTarif(_context); int weightBigerOnOneOfMaximumTarifWeightFactor = EntitySetuper.MAX_WRIGHT_ON_SETUPED_TARIF_WEIGHT_FACTOR + 1; DeliveryInfoRequestModel deliveryInfoRequestDto = new DeliveryInfoRequestModel(weightBigerOnOneOfMaximumTarifWeightFactor, way.LocalitySandLocalityId, way.LocalityGetLocalityId); var actualResult = Assert.Throws <UnsupportableWeightFactorException>(() => _deliveryService.GetDeliveryCostAndTimeDto(deliveryInfoRequestDto)); Assert.AreEqual(typeof(UnsupportableWeightFactorException), actualResult.GetType()); }
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]); }
public void initializeBillIncorrectInWay() { EntitySetuper.SetupWayWithTarif(_context); User setupAdresee = EntitySetuper.SetupAdresee(_context); User setupAdreser = EntitySetuper.SetupAdreser(_context); int incorrectLocalitySandId = 1000; int incorrectLocalityGetId = 100; DeliveryOrderCreateModel deliveryOrderCreateModel = new DeliveryOrderCreateModel(10, incorrectLocalitySandId, incorrectLocalityGetId, setupAdresee.Email); var actualResult = Assert.Throws <NoSuchWayException>(() => _billService.InitializeBill(deliveryOrderCreateModel, setupAdreser.UserName)); Assert.AreEqual(typeof(NoSuchWayException), actualResult.GetType()); }
public void initializeBillCorrectInCorrectAddressee() { Way setupWayWithTarif = EntitySetuper.SetupWayWithTarif(_context); String incorrectAdreseeEmail = "incorrectAdreseeEmail"; EntitySetuper.SetupAdresee(_context); User setupAdreser = EntitySetuper.SetupAdreser(_context); DeliveryOrderCreateModel deliveryOrderCreateModel = new DeliveryOrderCreateModel(10, setupWayWithTarif.LocalitySandLocalityId, setupWayWithTarif.LocalityGetLocalityId, incorrectAdreseeEmail); var actualResult = Assert.Throws <NoSuchUserException>(() => _billService.InitializeBill(deliveryOrderCreateModel, setupAdreser.UserName) ); Assert.AreEqual(typeof(NoSuchUserException), actualResult.GetType()); }
public void initializeBillCorrect() { Way setupWayWithTarif = EntitySetuper.SetupWayWithTarif(_context); User setupAdresee = EntitySetuper.SetupAdresee(_context); User setupAdreser = EntitySetuper.SetupAdreser(_context); DeliveryOrderCreateModel deliveryOrderCreateModel = new DeliveryOrderCreateModel(10, setupWayWithTarif.LocalitySandLocalityId, setupWayWithTarif.LocalityGetLocalityId, setupAdresee.Email); int expectedCost = 200; Bill billResult = _billService.InitializeBill(deliveryOrderCreateModel, setupAdreser.UserName); Assert.AreEqual(setupAdreser.Id, billResult.User.Id); Assert.False(billResult.IsDeliveryPaid); Assert.False(billResult.Delivery.IsPackageReceived); Assert.AreEqual(expectedCost, billResult.CostInCents); }