public async Task <IActionResult> Vote()
        {
            var model = new HomeVoteViewModel
            {
                totalVotes = (await repository.RetrieveAllAsync())
                             .Aggregate(ulong.MinValue, (nbVotes, image) => nbVotes += image.Votes)
            };

            return(View(model));
        }
        public async Task GetImagePair_ShouldReturnAllPairsAfterEnoughCalls()
        {
            // Arrange
            Init();
            int nbElements      = 5;
            int nbPossiblePairs = nbElements * (nbElements - 1);
            var controller      = new CatmashImageController(
                repository, pairGenerator, pairNumTracker, eloRatingCalculator, constants);
            var allImages = await repository.RetrieveAllAsync();

            var imageComparer = new ImagePropertiesComparer();
            List <ImagePair> expectedImagePairs = (from img1 in allImages
                                                   from img2 in allImages
                                                   where !imageComparer.Equals(img1, img2)
                                                   orderby img1.Id
                                                   orderby img2.Id
                                                   select new ImagePair {
                first = img1, second = img2
            }).ToList();

            // Act
            List <ImagePair> returnedImagePairs = new List <ImagePair>();

            for (int i = 0; i < nbPossiblePairs; i++)
            {
                returnedImagePairs.Add(await controller.GetImagePair());
            }
            returnedImagePairs = returnedImagePairs.OrderBy(img => img.first.Id).OrderBy(img => img.second.Id).ToList();

            //Assert
            Assert.Equal <ImagePair>(expectedImagePairs, returnedImagePairs, new ImagePairComparer(imageComparer));
        }
        public async Task Scores_ShouldReturnViewResult_WithAllImagesSortedByScore()
        {
            // Arrange
            Init();
            var controller           = new HomeController(logger, repository);
            var expectedSortedImages = (await repository.RetrieveAllAsync()).OrderByDescending(img => img.Score);

            // Act
            var result = await controller.Scores();

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <HomeScoresViewModel>(viewResult.ViewData.Model);

            Assert.Equal(expectedSortedImages, model.images);
        }