public IActionResult GetMediaByTitle(string title) { var currentMedia = _mediaRepository.GetByTitle(title); if (currentMedia == null) { return(NotFound()); } else { return(Ok(_mediaRepository.GetByTitle(title))); } }
public void MediaRepository_Update_UpdatesMedia() { //arrange IMediaRepo mediaRepo = GetInMemoryMediaRepository(); //act mediaRepo.Add(media); Media saveMedia = mediaRepo.GetByTitle(media.MediaName); saveMedia.Composer = "update composer"; mediaRepo.Update(saveMedia); Media updateMedia = mediaRepo.GetByTitle(media.MediaName); //assert Assert.Equal("update composer", updateMedia.Composer); }
public void MediaRepository_GetByUserName_ThrowsExceptionWhenUserNameNotFound() { //arrange IMediaRepo mediaRepo = GetInMemoryMediaRepository(); //act mediaRepo.Add(media); //assert Assert.ThrowsAny <ArgumentNullException>(() => mediaRepo.GetByTitle("NotExistingTitle")); }
public void MediaRepository_Update_ThrowsExceptionWhenUserIdNotFound() { //arrange IMediaRepo mediaRepo = GetInMemoryMediaRepository(); //act mediaRepo.Add(media); Media saveMedia = mediaRepo.GetByTitle(media.MediaName); saveMedia.MediaId = 0; //assert Assert.ThrowsAny <ArgumentNullException>(() => mediaRepo.Update(saveMedia)); }
public void MediaRepository_Add_AddsMedia() { //arrange IMediaRepo mediaRepo = GetInMemoryMediaRepository(); //act mediaRepo.Add(media); Media saveMedia = mediaRepo.GetByTitle(media.MediaName); //assert Assert.Equal(1, saveMedia.MediaId); Assert.Equal("test media name", saveMedia.MediaName); Assert.Equal("test composer", saveMedia.Composer); Assert.Equal("hello, this is a test description", saveMedia.Description); Assert.Equal(9, saveMedia.Rating); Assert.Equal("https://upload.wikimedia.org/wikipedia/en/8/8a/The_Avengers_%282012_film%29_poster.jpg", saveMedia.MediaUrl); Assert.True(saveMedia.Approved); }