Ejemplo n.º 1
0
        public async Task <ActionResult> User(string userName)
        {
            User user = _userManager.GetByUserName(userName);

            if (user == null)
            {
                return(HttpNotFound());
            }
            List <IntegrationInfo> integrationInfos = await GetUserIntegrationInfo(user);


            var viewModel = new UserPageViewModel
            {
                User = user,
                UserIntegrationInfos = integrationInfos,
                AverageRating        = _userRatingManger.GetAverageRating(user.ID),
                IsUserLoggedIn       = IsUserLoggedIn(),
                HasLoggedInUserRated = HasLoggedInUserRated(user.ID),
                IsUserFollowing      = IsUserFollowedToUser(user.ID)
            };

            try
            {
                viewModel.RecentContent = await _videoContentGetter.GetRecentVideos(user.ID, 7);
            }
            catch (Exception)
            {
                ViewBag.Message = "An error occured when loading recent content.";
            }

            return(View(nameof(User), viewModel));
        }
        public async Task GetRecentVideos_GreaterQtyRequestedThanActualReturnsAllActual_ListCountEqualsActual()
        {
            const int expectedCount = 29;
            var       videoCombiner = new IntegrationVideoCombiner(new YoutubeDataClientFake(), new TwitchClientFake(), new FakeBrothershipUnitOfWork());
            var       videos        = await videoCombiner.GetRecentVideos(1, 50);

            Assert.IsTrue(videos.Count == expectedCount);
        }
        public async Task GetRecentVideos_VideosReturned_ReturnedListNotNull()
        {
            var videoCombiner = new IntegrationVideoCombiner(new YoutubeDataClientFake(), new TwitchClientFake(), new FakeBrothershipUnitOfWork());
            var videos        = await videoCombiner.GetRecentVideos(1, 20);

            Assert.IsTrue(videos.Count > 1);
            foreach (var video in videos)
            {
                System.Diagnostics.Debug.WriteLine(video.Id + " " + video.ContentType + " " + video.UploadTime);
            }
        }
        public async Task GetRecentVideos_ReturnVideosAreNotTheSame_ItemsInOrder()
        {
            var videoCombiner = new IntegrationVideoCombiner(new YoutubeDataClientFake(), new TwitchClientFake(), new FakeBrothershipUnitOfWork());
            var videos        = await videoCombiner.GetRecentVideos(1, 25);

            VideoContent previousVideo = null;

            foreach (var video in videos)
            {
                System.Diagnostics.Debug.WriteLine(video.Id + " " + video.ContentType + " " + video.UploadTime);
            }

            foreach (var video in videos)
            {
                Assert.IsTrue(videos.Count(p => p.Id == video.Id) <= 1);

                previousVideo = video;
            }
        }