public async Task GetAllByTownIdAsync_ShouldReturnCorrectResult() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var parkingsRepository = new EfDeletableEntityRepository <Parking>(context); var parkingService = new ParkingsService(parkingsRepository); var seeder = new DbContextTestsSeeder(); await seeder.SeedParkingsAsync(context); var townId = await parkingsRepository.All() .Select(p => p.TownId) .FirstOrDefaultAsync(); var result = await parkingService.GetAllByTownIdAsync(townId); Assert.True(result.ToList().Count == 1, ErrorMessage); }
public async Task GetByCarIdAsync_ShouldReturnCorrectResult() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var townRepository = new EfDeletableEntityRepository <Town>(context); var parkingSlotRepository = new EfDeletableEntityRepository <ParkingSlot>(context); var parkingRepository = new EfDeletableEntityRepository <Parking>(context); var carRepository = new EfDeletableEntityRepository <Car>(context); var parkingsService = new ParkingsService(parkingRepository, parkingSlotRepository, townRepository, carRepository); var seeder = new DbContextTestsSeeder(); await seeder.SeedParkingsAsync(context); await seeder.SeedCarsAsync(context); var car = await carRepository.All().FirstOrDefaultAsync(); var result = await parkingsService.GetByCarIdAsync(car.Id); Assert.True(result.Id == car.ParkingId, ErrorMessage); }
public async Task GetAllByParkingAsync_ShouldReturnCorrectResult() { var context = ApplicationDbContextInMemoryFactory.InitializeContext(); var carsRepository = new EfDeletableEntityRepository <Car>(context); var tripsRepository = new EfDeletableEntityRepository <Trip>(context); var reservationsRepository = new EfDeletableEntityRepository <Reservation>(context); var parkingsRepository = new EfDeletableEntityRepository <Parking>(context); var parkingService = new ParkingsService(parkingsRepository); var carsService = new CarsService(carsRepository, tripsRepository, reservationsRepository, parkingService); var seeder = new DbContextTestsSeeder(); await seeder.SeedParkingsAsync(context); await seeder.SeedCarsAsync(context); var result = await carsService.GetAllByParkingAsync <CarsServiceAllModel>(4); var count = result.ToList().Count; Assert.True(count == 3, ErrorMessage); }