Ejemplo n.º 1
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.º 2
0
 public ActionResult Index()
 {
     ViewBag.VideosList = _service.GetAll();
     return(View());
 }