示例#1
0
        private async Task GetAllShouldReturnListOfBlogPostsFromDB()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;

            var dbContext = new ApplicationDbContext(options);

            dbContext.BlogPosts.Add(new BlogPost());

            await dbContext.SaveChangesAsync();

            var blogPostRepository = new EfDeletableEntityRepository <BlogPost>(dbContext);

            var service = new BlogPostService(blogPostRepository);

            Assert.True(service.GetAll().Count() == 1);
        }