Exemplo n.º 1
0
        public async Task GetAllByTownIdAsync_ShouldReturnCorrectResult()
        {
            var context               = ApplicationDbContextInMemoryFactory.InitializeContext();
            var townRepository        = new EfDeletableEntityRepository <Town>(context);
            var parkingSlotRepository = new EfDeletableEntityRepository <ParkingSlot>(context);
            var parkingsRepository    = new EfDeletableEntityRepository <Parking>(context);
            var parkingSlotsService   = new ParkingSlotsService(parkingSlotRepository, parkingsRepository, townRepository);
            var seeder = new DbContextTestsSeeder();
            await seeder.SeedParkingsAsync(context);

            await seeder.SeedParkingSlotsAsync(context);

            var townId = await parkingsRepository.All().Select(p => p.TownId).FirstOrDefaultAsync();

            var result = await parkingSlotsService.GetAllByTownIdAsync(townId);

            Assert.True(result.Count() == 4, ErrorMessage);
        }