Beispiel #1
0
        public async Task GetAllByCountryIdAsync_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);

            await seeder.SeedTownsAsync(context);

            var countryId = await parkingsRepository.All().Select(p => p.Town.CountryId).FirstOrDefaultAsync();

            var result = await parkingSlotsService.GetAllByCountryIdAsync(countryId);

            Assert.True(result.Count() == 4, ErrorMessage);
        }
        public async Task GetAllByCountryIdAsync_ShouldReturnCorrectResult()
        {
            MapperInitializer.InitializeMapper();
            var context           = ApplicationDbContextInMemoryFactory.InitializeContext();
            var townRepository    = new EfDeletableEntityRepository <Town>(context);
            var countryRepository = new EfDeletableEntityRepository <Country>(context);
            var townsService      = new TownsService(townRepository);
            var seeder            = new DbContextTestsSeeder();
            await seeder.SeedCountriesAsync(context);

            await seeder.SeedTownsAsync(context);

            var countryId = await countryRepository.All()
                            .Select(c => c.Id)
                            .FirstOrDefaultAsync();

            var result = await townsService.GetAllByCountryIdAsync(countryId);

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