public void ReturnFalse_When_Courier_IsNotFound_InDatabase() { // Arrange string fakeFirstName = "testFirstName"; string fakeLastName = "testLastName"; var fakeCouriers = new List <Courier>() { }.GetQueryableMockDbSet(); var ctxStub = new Mock <IOnlineStoreContext>(); var townServiceStub = new Mock <ITownService>(); var addressServiceStub = new Mock <IAddressService>(); var mapperStub = new Mock <IMapper>(); var courierService = new CourierService(ctxStub.Object, townServiceStub.Object, addressServiceStub.Object, mapperStub.Object); ctxStub .Setup(ctx => ctx.Couriers) .Returns(fakeCouriers.Object); // Act var result = courierService.CourierExistsByName(fakeFirstName, fakeLastName); // Assert Assert.AreEqual(false, result); }
public CourierController() { string dbConnection = ConfigurationManager.ConnectionStrings["CourierHelperDb"].ConnectionString; CourierService = new CourierService(dbConnection); RouteService = new RouteService(dbConnection); OrderService = new OrderService(dbConnection); }
public ActionResult DeleteConfirmed(int id) { CourierService m = db.CourierServices.Find(id); db.CourierServices.Remove(m); db.SaveChanges(); return(RedirectToAction("Index", "CourierServices")); }
public OrderManager(string connectionString, string mapBoxAccessToken) { _mapBoxService = new MapboxService(mapBoxAccessToken, MapBoxProfile.Driving); _orderService = new OrderService(connectionString); _courierService = new CourierService(connectionString); _pointService = new PointService(connectionString); _routeService = new RouteService(connectionString); _ordersQueue = new Queue <OrderDto>(); }
public ActionResult Edit([Bind(Include = "CourierID,Name")] CourierService m) { if (ModelState.IsValid) { db.Entry(m).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "CourierServices")); } return(View(m)); }
public ActionResult Create([Bind(Include = "CourierID,Name")] CourierService m) { if (ModelState.IsValid) { db.CourierServices.Add(m); db.SaveChanges(); return(RedirectToAction("Index", "CourierServices")); } return(View(m)); }
public async Task <IHttpActionResult> StartDelivery(Guid courierId, DeliveryDto delivery) { foreach (var order in delivery.Orders) { await OrderService.ChangeOrderStateAsync(order, OrderStateDto.Fulfillment); } await RouteService.AddRouteAsync(courierId, delivery.Route); await CourierService.ChangeCourierStateAsync(courierId, CourierStateDto.PerformsDelivery); return(Ok()); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CourierService m = db.CourierServices.Find(id); if (m == null) { return(HttpNotFound()); } return(View(m)); }
public void Throw_ArgumentNullException_When_CourierModels_IsNull() { // Arrange var ctxStub = new Mock <IOnlineStoreContext>(); var townServiceStub = new Mock <ITownService>(); var addressServiceStub = new Mock <IAddressService>(); var mapperStub = new Mock <IMapper>(); var courierService = new CourierService(ctxStub.Object, townServiceStub.Object, addressServiceStub.Object, mapperStub.Object); Action executingAddCourierRangeMethod = () => courierService.AddCourierRange(null); // Act & Assert Assert.ThrowsException <ArgumentNullException>(executingAddCourierRangeMethod); }
public void Throw_ArgumentNullException_When_FirstNameOrLastName_IsNullOrEmpty() { // Arrange string fakeFirstName = null; string fakeLastName = "testLastName"; var ctxStub = new Mock <IOnlineStoreContext>(); var townServiceStub = new Mock <ITownService>(); var addressServiceStub = new Mock <IAddressService>(); var mapperStub = new Mock <IMapper>(); var courierService = new CourierService(ctxStub.Object, townServiceStub.Object, addressServiceStub.Object, mapperStub.Object); Action executingCourierExistsByNameMethod = () => courierService.CourierExistsByName(fakeFirstName, fakeLastName); // Act & Assert Assert.ThrowsException <ArgumentNullException>(executingCourierExistsByNameMethod); }
public IHttpActionResult GetAll() { List <CourierDto> couriers = CourierService.GetAllCouriers(); return(Ok(couriers)); }
public void Invoke_ContextSaveChanges_When_ValidationsPass() { // Arrange var fakeAddressText = "testAddress"; var fakeTownName = "testTown"; var fakeCourierImportModel = new Mock <ICourierImportModel>(); var fakeCourierImportModels = new List <ICourierImportModel>() { fakeCourierImportModel.Object }; var fakeTown = new Town() { Name = fakeTownName }; var fakeTowns = new List <Town>() { fakeTown }.GetQueryableMockDbSet(); var fakeAddress = new Address() { AddressText = fakeAddressText, Town = fakeTown }; var fakeAddresses = new List <Address>() { fakeAddress }.GetQueryableMockDbSet(); var fakeCourier = new Mock <Courier>(); var fakeCouriers = new List <Courier>() { }.GetQueryableMockDbSet(); var mockCtx = new Mock <IOnlineStoreContext>(); var townServiceStub = new Mock <ITownService>(); var addressServiceStub = new Mock <IAddressService>(); var mapperStub = new Mock <IMapper>(); var courierService = new CourierService(mockCtx.Object, townServiceStub.Object, addressServiceStub.Object, mapperStub.Object); fakeCourierImportModel .SetupGet(cip => cip.Address) .Returns(fakeAddressText); fakeCourierImportModel .SetupGet(cip => cip.Town) .Returns(fakeTownName); mapperStub .Setup(m => m.Map <ICourierImportModel, Courier>(fakeCourierImportModel.Object)) .Returns(fakeCourier.Object); mockCtx .Setup(ctx => ctx.Towns) .Returns(fakeTowns.Object); mockCtx .Setup(ctx => ctx.Addresses) .Returns(fakeAddresses.Object); mockCtx .Setup(ctx => ctx.Couriers) .Returns(fakeCouriers.Object); // Act courierService.AddCourierRange(fakeCourierImportModels); // Assert mockCtx.Verify(c => c.SaveChanges(), Times.Once); }
/// <summary> /// Konstruktor modelu widoku kuriera /// </summary> public CourierViewModel() { DataService = new CourierService(); courier = new Courier(); AcceptCommand = new RelayCommand(AcceptExecute); }
public CourierController() { courierService = new CourierService(); Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); }
/// <summary> /// Konstruktor modelu widoku kurierów /// </summary> public CouriersViewModel() { AddCourierCommand = new RelayCommand(AddCourierExecute); DataService = new CourierService(); Couriers = new ObservableCollection <Courier>(); }
public Conditionals() { _courierService = new CourierService(); }
public CourierServiceTests() { _mapper = new Mock <IMapper>(); _repository = new Mock <ICourierRepository>(); _service = new CourierService(_repository.Object, _mapper.Object); }
public IHttpActionResult GetById(Guid courierId) { CourierDto courier = CourierService.GetCourierById(courierId); return(Ok(courier)); }
public Courier(int id, string pwd) { this.id = id; this.password = pwd; this.service = ServicesFactory.GetInstance().GetCourierService(); }
public async Task <IHttpActionResult> UpdateLocation(Guid courierId, [FromBody] PointDto location) { await CourierService.ChangeCourierLocationAsync(courierId, location); return(Ok()); }
public void Invoke_TownServiceCreate_When_CourierModelTown_DoesNotExists_InDatabase() { // Arrange var fakeAddressText = "testAddress"; var fakeTownName = "testTown"; var fakeCourierImportModel = new Mock <ICourierImportModel>(); var fakeCourierImportModels = new List <ICourierImportModel>() { fakeCourierImportModel.Object }; var fakeTown = new Town() { Name = fakeTownName }; var fakeTowns = new List <Town>() { }.GetQueryableMockDbSet(); var newFakeTowns = new List <Town>() { fakeTown }.GetQueryableMockDbSet(); var fakeAddress = new Address() { AddressText = fakeAddressText, Town = fakeTown }; var fakeAddresses = new List <Address>() { }.GetQueryableMockDbSet(); var newfakeAddresses = new List <Address>() { fakeAddress }.GetQueryableMockDbSet(); var fakeCourier = new Mock <Courier>(); var fakeCouriers = new List <Courier>() { }.GetQueryableMockDbSet(); var ctxStub = new Mock <IOnlineStoreContext>(); var mockTownService = new Mock <ITownService>(); var addressServiceStub = new Mock <IAddressService>(); var mapperStub = new Mock <IMapper>(); var courierService = new CourierService(ctxStub.Object, mockTownService.Object, addressServiceStub.Object, mapperStub.Object); Action addingTownToTowns = () => ctxStub .Setup(ctx => ctx.Towns) .Returns(newFakeTowns.Object); Action addingAddressToAddresses = () => ctxStub .Setup(ctx => ctx.Addresses) .Returns(newfakeAddresses.Object); fakeCourierImportModel .SetupGet(cip => cip.Address) .Returns(fakeAddressText); fakeCourierImportModel .SetupGet(cip => cip.Town) .Returns(fakeTownName); mapperStub .Setup(m => m.Map <ICourierImportModel, Courier>(fakeCourierImportModel.Object)) .Returns(fakeCourier.Object); ctxStub .Setup(ctx => ctx.Towns) .Returns(fakeTowns.Object); ctxStub .Setup(ctx => ctx.Addresses) .Returns(fakeAddresses.Object); ctxStub .Setup(ctx => ctx.Couriers) .Returns(fakeCouriers.Object); mockTownService .Setup(ts => ts.Create(fakeTownName)) .Callback(addingTownToTowns); addressServiceStub .Setup(addServ => addServ.Create(fakeAddressText, fakeTownName)) .Callback(addingAddressToAddresses); // Act courierService.AddCourierRange(fakeCourierImportModels); // Assert mockTownService.Verify(ts => ts.Create(fakeTownName), Times.Once); }
public CourierService GetCourierService() { CourierService courierService = null;//等待实现 return(courierService); }
public PriorityShippingCalculator() { _courierService = new CourierService(); }