public async Task Should_GetAllParkingInfo() { // Arrange var LHandleAllParkingInfo = new GetAllParkingInfoQueryHandler(FMainDbContext); var LRequest = new GetAllParkingInfoQuery(); // Act var LResult = await LHandleAllParkingInfo.Handle(LRequest, CancellationToken.None); // Assert LResult.Should().HaveCount(2); }
public IEnumerable <ParkingInfo> Handle(GetAllParkingInfoQuery _) { var parkings = _dbContext.Set <Models.Parking>() .Include(p => p.Places) .ToList(); return(parkings.Select(p => { return new ParkingInfo { Name = p.Name, IsOpened = p.IsOpened, MaximumPlaces = p.Places.Count, AvailablePlaces = p.IsOpened ? p.Places.Count(pp => pp.IsFree) : 0 }; })); }
public IEnumerable <ParkingInfo> GetAllParkingInfos() { var query = new GetAllParkingInfoQuery(); return(_queryHandler.Handle(query)); }