Example #1
0
        public void TestCountries()
        {
            var optionsBuilder = new DbContextOptionsBuilder <HomeMyDayDbContext>();

            optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString());
            HomeMyDayDbContext context = new HomeMyDayDbContext(optionsBuilder.Options);

            context.Countries.Add(new Country()
            {
                Id          = 1,
                CountryCode = "AZE",
                Name        = "Azerbaijan"
            });
            context.Countries.Add(new Country()
            {
                Id          = 2,
                CountryCode = "USA",
                Name        = "United States"
            });

            context.SaveChanges();

            ICountryRepository repository = new EFCountryRepository(context);

            Assert.Equal(2, repository.Countries.Count());
        }
Example #2
0
        public void TestNoCountries()
        {
            var optionsBuilder = new DbContextOptionsBuilder <HomeMyDayDbContext>();

            optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString());
            HomeMyDayDbContext context = new HomeMyDayDbContext(optionsBuilder.Options);

            ICountryRepository repository = new EFCountryRepository(context);

            Assert.Empty(repository.Countries);
        }