public async Task Handler_Gets_Book_Count_For_User() { var testQuery = new BookStatsGetQuery(Guid.NewGuid()); var books = _fixture .Build <BookRecord>() .With(b => b.User, new ApplicationUser { Id = testQuery.UserId.GetValueOrDefault() }) .With(b => b.UserId, testQuery.UserId) .CreateMany(); var notIncludedBook = _fixture .Build <BookRecord>() .With(b => b.UserId, Guid.NewGuid) .Create(); await _context.AddRangeAsync(books); await _context.AddAsync(notIncludedBook); await _context.SaveChangesAsync(); var results = await _handler.Handle(testQuery); results.BookCount.Should().Be(books.Count()).And.BeGreaterThan(0); }
public BookStatsGetQueryHandlerTests() { _fixture = new Fixture(); _fixture.Behaviors.Add(new OmitOnRecursionBehavior()); _context = InitializeDatabase(); _testQuery = new BookStatsGetQuery(null); _handler = new BookStatsGetQueryHandler(_context); }