public async Task Execute_WithOutOfOrderTitles_IsOrderedByTitle()
        {
            const string FIRST_TITLE = "Aardvarks";
            const string LAST_TITLE  = "Zoology";

            var mediaApi = new MockMediaRepository();

            mediaApi.AddAlbum(1, "Good times", 1);
            mediaApi.AddAlbum(2, LAST_TITLE, 1);
            mediaApi.AddAlbum(3, FIRST_TITLE, 1);

            var query   = new SearchAlbumsQuery();
            var handler = new SearchAlbumsQueryHandler(mediaApi, NullLogger <SearchAlbumsQueryHandler> .Instance);

            var result = await handler.ExecuteAsync(query);

            var firstTitle = result
                             .Select(a => a.Title)
                             .FirstOrDefault();

            var lastTitle = result
                            .Select(a => a.Title)
                            .Skip(2)
                            .FirstOrDefault();

            Assert.Equal(FIRST_TITLE, firstTitle);
            Assert.Equal(LAST_TITLE, lastTitle);
        }
        /// <summary>
        /// Creates a mock media respository with a set of basic seed data. The
        /// data is added with sequential ids.
        /// </summary>
        /// <param name="totalAlbums">The total number of albums to seed the respository with.</param>
        /// <param name="totalusers">
        /// The total number of user to seed the respository with. Albums are distributed to users
        /// evenly throughout the collection.
        /// </param>
        /// <param name="photosPerAlbum">The number of photos to seed each album with.</param>
        public static MockMediaRepository CreateWithData(
            int totalAlbums,
            int totalusers,
            int photosPerAlbum
            )
        {
            var mediaRepository = new MockMediaRepository();

            int userId = 1;

            for (int albumId = 1; albumId <= totalAlbums; albumId++)
            {
                mediaRepository.AddAlbum(albumId, userId);

                for (int photoId = 1; photoId <= photosPerAlbum; photoId++)
                {
                    mediaRepository.AddPhoto(photoId, albumId);
                }

                // distribute users evenly throughout the colleciton
                if (userId > totalusers)
                {
                    userId = 1;
                }
                else
                {
                    userId++;
                }
            }

            return(mediaRepository);
        }