Ejemplo n.º 1
0
        public async Task GetMaxPagesShouldReturnCorrectNumber()
        {
            var dbOptions = new DbContextOptionsBuilder <ApplicationDbContext>()
                            .UseInMemoryDatabase("test");
            var context = new ApplicationDbContext(dbOptions.Options);

            var postsService = new PostsService(context, null);

            var school = new School();
            var user   = new ApplicationUser();
            await context.Schools.AddAsync(school);

            await context.Users.AddAsync(user);

            await context.SaveChangesAsync();

            await postsService.CreatePost("Content", user, school.Id);

            var maxPages = postsService.GetMaxPages(school.Id);

            Assert.That(maxPages == 1);
        }