Exemplo n.º 1
0
        public async Task GetLatestVideosGetsNoMoreThanFiveUniqueVideos()
        {
            var store = new Mock <IUserStore <ApplicationUser> >();

            var userManager = new UserManager <ApplicationUser>(store.Object, null, null, null, null, null, null, null, null);

            var videoList = new List <Video>();
            var videoRepo = new Mock <IDeletableEntityRepository <Video> >();

            videoRepo.Setup(x => x.All()).Returns(videoList.AsQueryable());
            videoRepo.Setup(x => x.AddAsync(It.IsAny <Video>()))
            .Callback((Video r) => videoList.Add(r));

            var videoService = new VideosService(videoRepo.Object);

            await videoService.CreateAsync(test.Title, test.Description, test.VideoUrl, test.Category);

            await videoService.CreateAsync(test2.Title, test2.Description, test2.VideoUrl, test2.Category);

            var listResult = videoService.GetLatestVideos();

            Assert.Equal(videoList.OrderByDescending(x => x.CreatedOn), listResult);
        }