Beispiel #1
0
        public async Task CreateReviewShouldReturnCorrectId()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            var reviewsService = new ReviewsService(db);

            var resultId = await reviewsService.CreateReviewAsync("description1", "author1", 1, ReadingProgress.ToRead, true, 10);

            Assert.Equal(1, resultId);
        }
Beispiel #2
0
        public async Task CreateReviewShouldAddParentId()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            var reviewsService = new ReviewsService(db);

            await reviewsService.CreateReviewAsync("description1", "author1", 1, ReadingProgress.ToRead, true, 10);

            var result = await db.Reviews.FirstOrDefaultAsync();

            Assert.Equal(1, await db.Reviews.CountAsync());
            Assert.Equal(10, result.ParentId);
        }
Beispiel #3
0
        public async Task CreateReviewShouldAddInDatabase(string description, string authorId, int bookId, ReadingProgress progress, bool thisEdition)
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            var reviewsService = new ReviewsService(db);

            await reviewsService.CreateReviewAsync(description, authorId, bookId, progress, thisEdition);

            var result = await db.Reviews.FirstOrDefaultAsync();

            Assert.Equal(1, await db.Reviews.CountAsync());
            Assert.Equal(description, result.Description);
            Assert.Equal(authorId, result.AuthorId);
            Assert.Equal(bookId, result.BookId);
            Assert.Equal(progress, result.ReadingProgress);
            Assert.Equal(thisEdition, result.ThisEdition);
            Assert.Null(result.ParentId);
        }