public async Task Should_Get_Parking_Lots_By_Name() { // given var scope = Factory.Services.CreateScope(); var scopedServices = scope.ServiceProvider; ParkingLotContext context = scopedServices.GetRequiredService <ParkingLotContext>(); // when int startindex = 1; int endindex = 2; ParkingLotDto parkingLotDto1 = new ParkingLotDto() { Name = "parkinglot1", Capacity = 4, Location = "Beijing", }; ParkingLotDto parkingLotDto2 = new ParkingLotDto() { Name = "parkinglot2", Capacity = 3, Location = "Beijing", }; ParkingLotService parkingLotService = new ParkingLotService(context); await parkingLotService.AddParkingLot(parkingLotDto1); await parkingLotService.AddParkingLot(parkingLotDto2); var parkingLot = await parkingLotService.GetByName("parkinglot2"); Assert.Equal(parkingLotDto2, parkingLot); }
public async Task Should_get_parkingLot_Successfully_by_name_Via_Service() { var scope = Factory.Services.CreateScope(); var scopedServices = scope.ServiceProvider; ParkingLotDbContext context = scopedServices.GetRequiredService <ParkingLotDbContext>(); context.ParkingLots.RemoveRange(context.ParkingLots); context.SaveChanges(); ParkingLotService parkingLotService = new ParkingLotService(context); await parkingLotService.AddParkingLot(parkingLotDto1); var getByName = await parkingLotService.GetByName("IBM"); var parkingLotDto1String = JsonConvert.SerializeObject(parkingLotDto1); var getByNameString = JsonConvert.SerializeObject(getByName); Assert.Equal(parkingLotDto1String, getByNameString); }