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

            var db = new AlexandriaDbContext(options);
            await db.AddRangeAsync(
                new Review
            {
                Description = "description1",
                AuthorId    = "author1",
                BookId      = 1,
            },
                new Review
            {
                Description = "description2",
                AuthorId    = "author1",
                BookId      = 1,
                ParentId    = 1,
            });

            await db.SaveChangesAsync();

            var reviewsService = new ReviewsService(db);

            var result = await reviewsService.GetAuthorIdByIdAsync(5);

            Assert.Null(result);
        }