Ejemplo n.º 1
0
        public async Task CreateNewVideoShouldAddCorrectly()
        {
            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);

            Assert.Equal(videoList[0].Title, this.test.Title);
            Assert.Equal(videoList[1].Title, this.test2.Title);
            Assert.NotEqual(videoList[1].Title, this.test.Title);
        }
Ejemplo n.º 2
0
        public async Task GetEmbededLinkWorkFine()
        {
            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 embededLink = videoService.GetEmbededVideoLink(test.VideoUrl);

            var embededLink2 = videoService.GetEmbededVideoLink(test2.VideoUrl);

            Assert.Equal("w2ze3Z6BAmg", embededLink);
            Assert.Equal("03ILbXdE8b4", embededLink2);
        }
Ejemplo n.º 3
0
        public async Task GetAllReturnsAllVideosCorrectly()
        {
            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 resultList = videoService.GetAll().ToList().OrderBy(x => x.CreatedOn).ToList();

            Assert.Equal(videoList[0].Title, resultList[0].Title);
            Assert.Equal(videoList[0].Id, resultList[0].Id);
            Assert.Equal(videoList[1].Title, resultList[1].Title);
            Assert.Equal(videoList[1].Id, resultList[1].Id);
        }
Ejemplo n.º 4
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);
        }