Пример #1
0
        public async Task Should_add_parkingOrder_when_add_parkingOrder_via_parkingOrderService()
        {
            // given
            var scope                 = Factory.Services.CreateScope();
            var scopedServices        = scope.ServiceProvider;
            ParkingLotContext context = scopedServices.GetRequiredService <ParkingLotContext>();
            var parkingOrderDto       = GenerateParkingOrderDto();
            ParkingOrderService parkingOrderService = new ParkingOrderService(context);

            // when
            var parkingOrderNumber = await parkingOrderService.AddParkingOrder(parkingOrderDto);

            var foundParkingOrder = await context.ParkingOrders.FirstOrDefaultAsync(parkingOrderEntity => parkingOrderEntity.OrderNumber == parkingOrderNumber);

            // then
            Assert.Equal(parkingOrderDto.OrderNumber, foundParkingOrder.OrderNumber);
        }
Пример #2
0
        public async Task Should_get_correct_parkingOrder_when_get_parkingOrder_via_parkingOrderService()
        {
            // given
            var scope                               = Factory.Services.CreateScope();
            var scopedServices                      = scope.ServiceProvider;
            ParkingLotContext   context             = scopedServices.GetRequiredService <ParkingLotContext>();
            ParkingOrderService parkingOrderService = new ParkingOrderService(context);
            var parkingOrderDtoList                 = GenerateParkingOrderDtoList();

            foreach (var parkingOrderDto in parkingOrderDtoList)
            {
                await parkingOrderService.AddParkingOrder(parkingOrderDto);
            }

            // when
            var parkingOrder = await parkingOrderService.GetParkingOrderByOrderNumber(parkingOrderDtoList[0].OrderNumber);

            // then
            Assert.Equal(parkingOrderDtoList[0], parkingOrder);
        }
Пример #3
0
        public async Task Should_get_all_parkingOrders_when_get_parkingOrders_via_parkingOrderService()
        {
            // given
            var scope                               = Factory.Services.CreateScope();
            var scopedServices                      = scope.ServiceProvider;
            ParkingLotContext   context             = scopedServices.GetRequiredService <ParkingLotContext>();
            ParkingOrderService parkingOrderService = new ParkingOrderService(context);
            var parkingOrderDtoList                 = GenerateParkingOrderDtoList();

            foreach (var parkingOrderDto in parkingOrderDtoList)
            {
                await parkingOrderService.AddParkingOrder(parkingOrderDto);
            }

            // when
            var allParkingOrders = await parkingOrderService.GetAllParkingOrders();

            // then
            Assert.Equal(5, allParkingOrders.Count());
        }
Пример #4
0
        public async Task Should_update_parkingOrder_when_update_parkingOrder_via_parkingOrderService()
        {
            // given
            var scope                               = Factory.Services.CreateScope();
            var scopedServices                      = scope.ServiceProvider;
            ParkingLotContext   context             = scopedServices.GetRequiredService <ParkingLotContext>();
            ParkingOrderService parkingOrderService = new ParkingOrderService(context);
            var parkingOrderDtoList                 = GenerateParkingOrderDtoList();

            foreach (var parkingOrderDto in parkingOrderDtoList)
            {
                await parkingOrderService.AddParkingOrder(parkingOrderDto);
            }

            UpdateParkingOrderDto updateParkingOrderDto = new UpdateParkingOrderDto("closed");

            // when
            var changedParkingOrder = await parkingOrderService.UpdateParkingOrder(parkingOrderDtoList[0].OrderNumber, updateParkingOrderDto);

            // then
            Assert.Equal(updateParkingOrderDto.CloseTime, changedParkingOrder.CloseTime);
            Assert.Equal(updateParkingOrderDto.OrderStatus, changedParkingOrder.OrderStatus);
        }
Пример #5
0
        // private readonly List<ParkingOrderDto> parkingOrderDtos = new ParkingOrderDto();

        public ParkingOrderController(ParkingOrderService parkingOrderService)
        {
            this.parkingOrderService = parkingOrderService;
        }
Пример #6
0
 public ParkingOrdersController(ParkingOrderService parkingOrderService, ParkingLotService parkingLotService)
 {
     this.parkingOrderService = parkingOrderService;
     this.parkingLotService   = parkingLotService;
 }