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); }
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); }
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()); }
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); }
// private readonly List<ParkingOrderDto> parkingOrderDtos = new ParkingOrderDto(); public ParkingOrderController(ParkingOrderService parkingOrderService) { this.parkingOrderService = parkingOrderService; }
public ParkingOrdersController(ParkingOrderService parkingOrderService, ParkingLotService parkingLotService) { this.parkingOrderService = parkingOrderService; this.parkingLotService = parkingLotService; }