예제 #1
0
        public async Task Should_delete_specific_parkingLot_when_give_name_Test()
        {
            var scope                       = Factory.Services.CreateScope();
            var scopeServices               = scope.ServiceProvider;
            ParkingLotDbContext context     = scopeServices.GetRequiredService <ParkingLotDbContext>();
            ParkingLotDto       parkingLot1 = new ParkingLotDto();

            parkingLot1.Name     = "345";
            parkingLot1.Capacity = 0;
            parkingLot1.Location = "southRoad";
            ParkingLotDto parkingLot2 = new ParkingLotDto();

            parkingLot2.Name     = "234";
            parkingLot2.Capacity = 0;
            parkingLot2.Location = "southRoad";

            ParkingLotService parkingLotService = new ParkingLotService(context);
            var name1 = await parkingLotService.AddParkingLot(parkingLot1);

            var name2 = await parkingLotService.AddParkingLot(parkingLot2);

            await parkingLotService.DeleteParkingLot(parkingLot1.Name);

            Assert.Equal(1, context.ParkingLots.Count());
        }
        public async Task Should_not_delete_parkingLot_when_can_not_find_by_name_via_service()
        {
            var scope          = Factory.Services.CreateScope();
            var scopedServices = scope.ServiceProvider;

            ParkingLotDbContext context           = scopedServices.GetRequiredService <ParkingLotDbContext>();
            ParkingLotService   parkingLotService = new ParkingLotService(context);

            context.ParkingLots.RemoveRange(context.ParkingLots);
            context.SaveChanges();
            var addReturn1 = await parkingLotService.AddParkingLot(parkingLotDto1);

            var addReturn2 = await parkingLotService.AddParkingLot(parkingLotDto2);

            await parkingLotService.DeleteParkingLot(addReturn1);

            await parkingLotService.DeleteParkingLot(addReturn1);

            Assert.Equal(1, context.ParkingLots.Count());
        }
예제 #3
0
        public async Task <ActionResult <int> > DeleteParkingLotAsync(string name)
        {
            if (!await parkingLotService.ContainExistingParkingLot(name))
            {
                return(NotFound());
            }

            await parkingLotService.DeleteParkingLot(name);

            return(NoContent());
        }
        public async Task Story1_AC2_Should_delete_parkingLot()
        {
            // given
            var parkingLot = new ParkingLot("Lot1", 10, "location1");

            // when
            var name = await service.AddParkingLot(parkingLot);

            await service.DeleteParkingLot(name);

            // then
            Assert.Equal(0, context.ParkingLots.CountAsync().Result);
        }
        public async Task Should_delete_parkingLot_when_delete_parkingLot_by_name_via_parkingLotService()
        {
            var scope          = Factory.Services.CreateScope();
            var scopedServices = scope.ServiceProvider;

            ParkingLotContext context = scopedServices.GetRequiredService <ParkingLotContext>();
            var parkingLotDto         = GenerateParkingLotDto();

            ParkingLotService parkingLotService = new ParkingLotService(context);

            var parkingLotName = await parkingLotService.AddParkingLot(parkingLotDto);

            Assert.Equal(1, context.ParkingLots.Count());

            await parkingLotService.DeleteParkingLot(parkingLotName);

            Assert.Equal(0, context.ParkingLots.Count());
        }
        public async Task <IActionResult> Delete(string name)
        {
            var lotFound = await service.GetParkingLotByName(name);

            if (lotFound == null)
            {
                return(NotFound("no lot match name"));
            }

            var orderOpen = orderService.GetAllOrderEntities().Result
                            .FirstOrDefault(order => order.ParkingLotName == name && order.Status == Status.Open);

            if (orderOpen != null)
            {
                return(BadRequest("some car still in the lot"));
            }

            await service.DeleteParkingLot(name);

            return(NoContent());
        }
        public async Task <ActionResult> Delete(int id)
        {
            await parkingLotService.DeleteParkingLot(id);

            return(this.NoContent());
        }
        public async Task <ActionResult> Delete(string name)
        {
            await parkingLotService.DeleteParkingLot(name);

            return(NoContent());
        }