コード例 #1
0
        public void TestFaqFilledRepository()
        {
            var optionsBuilder = new DbContextOptionsBuilder <HomeMyDayDbContext>();

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

            context.FaqCategory.AddRange(
                new FaqCategory()
            {
                CategoryName = "TestA"
            },
                new FaqCategory()
            {
                CategoryName = "TestB"
            },
                new FaqCategory()
            {
                CategoryName = "TestC"
            }
                );
            context.SaveChanges();

            IFaqRepository repository = new EFFaqRepository(context);

            Assert.True(repository.GetCategoriesAndQuestions().Count() == 3);
        }
コード例 #2
0
        public void TestFaqEmptyRepository()
        {
            var optionsBuilder = new DbContextOptionsBuilder <HomeMyDayDbContext>();

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

            Assert.Empty(repository.GetCategoriesAndQuestions());
        }