public void ShouldBeReturnResultsAfterUpdateOneVideoContent()
        {
            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      = "videoId3",
                Title        = "title3",
                Thumbnail    = "thumbnail3",
                Tag          = "tag3_Updated",
                SrcUri       = "https://www.youtube.com/watch?v=",
                SrcExtention = "youtube",
                AppUserId    = 2,
                Duration     = 3000
            };

            Assert.Equal(vc.Tag, videocontentservice.Update("videoId3", vc).VideoContent.Tag);
            Assert.Equal(vc.Title, videocontentservice.Update("videoId3", vc).VideoContent.Title);
            Assert.Equal(vc.SrcUri, videocontentservice.Update("videoId3", vc).VideoContent.SrcUri);
            Assert.Equal(vc.SrcExtention, videocontentservice.Update("videoId3", vc).VideoContent.SrcExtention);
        }
Пример #2
0
        public ActionResult Put(string id, [FromBody] VideoContentModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }

            var videoContent = _mapper.Map <VideoContentModel, VideoContent>(model);
            var result       = _videoContentService.Update(id, videoContent);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }

            var videoContentModel = _mapper.Map <VideoContent, VideoContentModel>(result.VideoContent);

            return(Ok(videoContentModel));
        }