public async Task Handler_Returns_Featured_User_Items_When_Request_User_Id_Is_Null() { var featuredUserAlbum = _fixture .Build <AlbumRecord>() .With(a => a.IsShowcased, true) .With(a => a.UserId, _globalSettings.FeaturedAlbumUserId) .Without(a => a.User) .Create(); var featuredUserBook = _fixture .Build <BookRecord>() .With(b => b.IsShowcased, true) .With(b => b.UserId, _globalSettings.FeaturedBookUserId) .Without(b => b.User) .Create(); var featuredUserGame = _fixture .Build <GameRecord>() .With(g => g.IsShowcased, true) .With(g => g.UserId, _globalSettings.FeaturedGameUserId) .Without(g => g.User) .Create(); var featuredUserMovie = _fixture .Build <MovieRecord>() .With(m => m.IsShowcased, true) .With(m => m.UserId, _globalSettings.FeaturedMovieUserId) .Without(m => m.User) .Create(); await _context.AlbumRecords.AddAsync(featuredUserAlbum); await _context.BookRecords.AddAsync(featuredUserBook); await _context.GameRecords.AddAsync(featuredUserGame); await _context.MovieRecords.AddAsync(featuredUserMovie); await InitializeRecords(); var testQuery = new ShowcaseGetListQuery(null); var result = await _handler.Handle(testQuery); result.ShowcasedAlbums.Should().NotBeEmpty(); result.ShowcasedAlbums.All(a => a.UserId == _globalSettings.FeaturedAlbumUserId).Should().BeTrue(); result.ShowcasedBooks.Should().NotBeEmpty(); result.ShowcasedBooks.All(b => b.UserId == _globalSettings.FeaturedBookUserId).Should().BeTrue(); result.ShowcasedGames.Should().NotBeEmpty(); result.ShowcasedGames.All(g => g.UserId == _globalSettings.FeaturedGameUserId).Should().BeTrue(); result.ShowcasedMovies.Should().NotBeEmpty(); result.ShowcasedMovies.All(m => m.UserId == _globalSettings.FeaturedMovieUserId).Should().BeTrue(); }
public ShowcaseListGetListQueryHandlerTests() { _fixture = new Fixture(); _fixture.Behaviors.Add(new OmitOnRecursionBehavior()); _context = InitializeDatabase(); _globalSettings = _fixture.Create <GlobalSettings>(); _testQuery = new ShowcaseGetListQuery(Guid.NewGuid()); _handler = new ShowcaseGetListQueryHandler(_globalSettings, _context); }