Ejemplo n.º 1
0
        public ActionResult Index()
        {
            var models  = new List <VideoContentModel>();
            var results = _videoContentService.List();

            foreach (var result in results)
            {
                var videoContentM = _mapper.Map <VideoContent, VideoContentModel>(result);
                models.Add(videoContentM);
            }

            return(Ok(models));
        }
        public void ShouldResturnVideoContents()
        {
            var options = new DbContextOptionsBuilder <EttvDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .Options;
            var context = new EttvDbContext(options);

            Seed(context);

            var videocontentservice = new VideoContentService(unitOfWork: new UnitOfWork(context));

            Assert.Equal("title1", videocontentservice.List().Where(x => x.VideoId == "videoId1").SingleOrDefault().Title);
            Assert.Equal("title3", videocontentservice.List().Where(x => x.VideoId == "videoId3").LastOrDefault().Title);
        }
        public void ShouldBeReturnResultsAfterAddOneVideoContent()
        {
            var options = new DbContextOptionsBuilder <EttvDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .Options;
            var context = new EttvDbContext(options);

            Seed(context);

            var videocontentservice = new VideoContentService(unitOfWork: new UnitOfWork(context));

            VideoContent vc = new VideoContent
            {
                VideoId      = "videoId4",
                Title        = "title4",
                Thumbnail    = "thumbnail4",
                Tag          = "tag4",
                SrcUri       = "https://www.youtube.com/watch?v=",
                SrcExtention = "youtube",
                AppUserId    = 1,
                Duration     = 1000
            };

            Assert.Equal(vc, videocontentservice.Save(vc).VideoContent);
            Assert.Equal(4, videocontentservice.List().Count());
        }
        public void ShouldBeReturnResultsAfterDeleteOneVideoContent()
        {
            var options = new DbContextOptionsBuilder <EttvDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .Options;
            var context = new EttvDbContext(options);

            Seed(context);

            var videocontentservice = new VideoContentService(unitOfWork: new UnitOfWork(context));

            VideoContent vc = videocontentservice.Delete("videoId1").VideoContent;

            Assert.Equal("tag1", vc.Tag);
            Assert.Equal("title1", vc.Title);
            Assert.Equal(2, videocontentservice.List().Count());
        }