Exemple #1
0
        public async Task CardRepository_GetByIdWithDetailsAsync_ReturnsCardByIdAndIncludesBooks()
        {
            //Arrange
            using var context = new LibraryDbContext(UnitTestHelper.GetUnitTestDbOptions());
            var cardRepository = new CardRepository(context);
            var expectedCard   = context.Cards.AsNoTracking().Include(x => x.Books).Include(x => x.Reader).FirstOrDefault(x => x.Id == 1);

            //Act
            var card = await cardRepository.GetByIdWithDetailsAsync(1);

            //Assert
            Assert.That(card, Is.EqualTo(expectedCard).Using(new CardEqualityComparer()));
            Assert.That(card.Books, Is.EqualTo(expectedCard.Books).Using(new HistoryEqualityComparer()));
            Assert.That(card.Reader, Is.EqualTo(expectedCard.Reader).Using(new ReaderEqualityComparer()));
        }