public async Task Should_CloseOrder_Success_Via_ParkingLotService() { //Given var context = GetParkingLotDbContext(); ParkingLotApiService parkingLotApiService = new ParkingLotApiService(context); List <ParkinglotDTO> parkingLotDtos = GenerateSomeParkinglots(); foreach (var parkingLotDto in parkingLotDtos) { await parkingLotApiService.AddParkingLotAsnyc(parkingLotDto); } OrderDto newOrderDto = new OrderDto() { OrderNumber = Guid.NewGuid(), NameOfParkingLot = "SuperPark_1", PlateNumber = "RJ_963824", CreationTime = DateTime.Now, }; await parkingLotApiService.CreateOrder(newOrderDto); //When await parkingLotApiService.CloseOrder(newOrderDto); var closedOrder = context.Orders.FirstOrDefault(order => order.OrderNumber == newOrderDto.OrderNumber); //Then Assert.Equal("Closed", closedOrder.OrderStatus); }
public async Task Should_CreateOrder_Success_Via_ParkingLotService() { //Given var context = GetParkingLotDbContext(); ParkingLotApiService parkingLotApiService = new ParkingLotApiService(context); List <ParkinglotDTO> parkingLotDtos = GenerateSomeParkinglots(); foreach (var parkingLotDto in parkingLotDtos) { await parkingLotApiService.AddParkingLotAsnyc(parkingLotDto); } OrderDto newOrderDto = new OrderDto() { OrderNumber = Guid.NewGuid(), NameOfParkingLot = "SuperPark_1", PlateNumber = "RJ_963824", CreationTime = DateTime.Now, }; //When var newOrderId = await parkingLotApiService.CreateOrder(newOrderDto); var actualOrderDto = await parkingLotApiService.GetOrderById(newOrderId); //Then Assert.Equal(newOrderDto, actualOrderDto); }
public async Task Should_Patch_Can_Change_Capacity_Success_Via_ParkingLotService() { //Given var context = GetParkingLotDbContext(); ParkingLotApiService parkingLotApiService = new ParkingLotApiService(context); List <ParkinglotDTO> parkingLotDtos = GenerateSomeParkinglots(); foreach (var parkingLotDto in parkingLotDtos) { await parkingLotApiService.AddParkingLotAsnyc(parkingLotDto); } UpdateModel updateModel = new UpdateModel("SuperPark_1", 30); var expectedCapacity = updateModel.Capacity; //When var actualCapacity = await parkingLotApiService.ChangeCapacity(updateModel); //Then Assert.Equal(expectedCapacity, actualCapacity); }
public async Task Should_Create_Parkinglot_Success_Via_ParkingLotService() { //Given var context = GetParkingLotDbContext(); ParkinglotDTO parkinglotDto = new ParkinglotDTO() { Name = "SuperPark_1", Capacity = 10, Location = "WuDaoKong" }; ParkingLotApiService parkingLotApiService = new ParkingLotApiService(context); //When var addedParkinglotID = await parkingLotApiService.AddParkingLotAsnyc(parkinglotDto); var returnParkinglot = await parkingLotApiService.GetById(addedParkinglotID); //Then Assert.Equal(parkinglotDto, returnParkinglot); }
public async Task Should_Delete_Parkinglot_Success_Via_ParkingLotService() { //Given var context = GetParkingLotDbContext(); ParkingLotApiService parkingLotApiService = new ParkingLotApiService(context); List <ParkinglotDTO> parkingLotDtos = GenerateSomeParkinglots(); foreach (var parkingLotDto in parkingLotDtos) { await parkingLotApiService.AddParkingLotAsnyc(parkingLotDto); } var expectedCount = context.Parkinglots.ToList().Count - 1; //When await parkingLotApiService.DeleteById(context.Parkinglots.ToList()[0].ID); var actualCount = context.Parkinglots.ToList().Count; //Then Assert.Equal(expectedCount, actualCount); }
public async Task Should_Get_Parkinglot_By_Name_Success_Via_ParkingLotService() { //Given var context = GetParkingLotDbContext(); ParkingLotApiService parkingLotApiService = new ParkingLotApiService(context); List <ParkinglotDTO> parkingLotDtos = GenerateSomeParkinglots(); foreach (var parkingLotDto in parkingLotDtos) { await parkingLotApiService.AddParkingLotAsnyc(parkingLotDto); } var testName = "SuperPark_1"; var parkingLot = context.Parkinglots.FirstOrDefault(parkingLot => parkingLot.Name == testName); var expectedDto = new ParkinglotDTO(parkingLot); //When var actualDto = await parkingLotApiService.GetByName(testName); //Then Assert.Equal(expectedDto, actualDto); }
public ParkingLotApiController(ParkingLotApiService parkingLotService) { this.parkingLotService = parkingLotService; }