public void GetAllShows() { //Arange var service = new ShowService(); var show = new Show { Name = "Test Retrieval", Description = "Retrieved Show", ThumbnailUrl = "https://upload.wikimedia.org/wikipedia/en/1/18/Shaw_Media_Logo_2012.png", VideoUrl = "http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4" }; var addedShow = service.Post(show); //Act var retrievedShows = service.GetAllShows(); //Assert Assert.IsTrue(retrievedShows.Count() > 0); var showsWithId = retrievedShows.Where(s => s.Id == addedShow.Id); Assert.AreEqual(showsWithId.Count(), 1); var showWithId = showsWithId.First(); Assert.AreEqual(showWithId.Id, addedShow.Id); Assert.AreEqual(showWithId.Name, addedShow.Name); Assert.AreEqual(showWithId.Description, addedShow.Description); Assert.AreEqual(showWithId.ThumbnailUrl, addedShow.ThumbnailUrl); Assert.AreEqual(showWithId.VideoUrl, addedShow.VideoUrl); }
public bool AddShow(Show showAdd) { try { this.Shows = AddShowtoList(showAdd, this.Shows); return true; } catch (Exception) { return false; } }
public void DeleteShow() { //Arrange var service = new ShowService(); var show = new Show { Name = "Test Creation ", Description = "Created Show", ThumbnailUrl = "https://upload.wikimedia.org/wikipedia/en/1/18/Shaw_Media_Logo_2012.png", VideoUrl = "http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4" }; var addedShow = service.Post(show); //Act bool result = service.Delete(addedShow.Id); //Assert Assert.IsTrue(result); }
public void CreateShow() { //Arange var controller = new ShowController(new ShowService()); var show = new Show { Name = "Test Creation of Show", Description = "Description of Created Show", ThumbnailUrl = "https://upload.wikimedia.org/wikipedia/en/1/18/Shaw_Media_Logo_2012.png", VideoUrl = "http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4" }; //Act var addedShow =controller.Post(show); //Assert Assert.AreNotEqual(addedShow.Id, 0); Assert.AreEqual(addedShow.Name, show.Name); Assert.AreEqual(addedShow.Description, show.Description); Assert.AreEqual(addedShow.ThumbnailUrl, show.ThumbnailUrl); Assert.AreEqual(addedShow.VideoUrl, show.VideoUrl); }
public void GetShow() { //Arange var service = new ShowService(); var show = new Show { Name = "Test Retrieval ", Description = "Retrieved Show", ThumbnailUrl = "https://upload.wikimedia.org/wikipedia/en/1/18/Shaw_Media_Logo_2012.png", VideoUrl = "http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4" }; var addedShow = service.Post(show); //Act var retrievedShow = service.GetById(addedShow.Id); //Assert Assert.AreEqual(retrievedShow.Id, addedShow.Id); Assert.AreEqual(retrievedShow.Name, addedShow.Name); Assert.AreEqual(retrievedShow.Description, addedShow.Description); Assert.AreEqual(retrievedShow.ThumbnailUrl, addedShow.ThumbnailUrl); Assert.AreEqual(retrievedShow.VideoUrl, addedShow.VideoUrl); }
public void UpdateShow() { //Arrange var service = new ShowService(); var show = new Show { Name = "Test Creation", Description = " Created Show", ThumbnailUrl = "https://upload.wikimedia.org/wikipedia/en/thumb/f/fa/Shaw_Communications_logo_(1997).svg/220px-Shaw_Communications_logo_(1997).svg.png", VideoUrl = "http://techslides.com/demos/sample-videos/small.mp4" }; var addedShow = service.Post(show); //Act var ShowToUpdate = addedShow; ShowToUpdate.Name = "Updated Name"; ShowToUpdate.Description = "Updated Description"; ShowToUpdate.ThumbnailUrl = "https://upload.wikimedia.org/wikipedia/en/1/18/Shaw_Media_Logo_2012.png"; ShowToUpdate.VideoUrl = "http://videoupdate.com"; var updatedShow = service.Put(ShowToUpdate); //Assert Assert.AreEqual(updatedShow.Id, ShowToUpdate.Id); Assert.AreEqual(updatedShow.Name, ShowToUpdate.Name); Assert.AreEqual(updatedShow.Description, ShowToUpdate.Description); Assert.AreEqual(updatedShow.ThumbnailUrl, show.ThumbnailUrl); Assert.AreEqual(updatedShow.VideoUrl, show.VideoUrl); }
public Show Put(Show show) { return _showService.Put(show); }
public Show Put(Show show) { var result = ShowContext.Shows.Where(s => s.Id == show.Id); if (result.Count() < 1) throw new HttpResponseException(HttpStatusCode.NotFound); var retrievedShow = result.First(); retrievedShow.Name = show.Name; retrievedShow.Description = show.Description; ShowContext.SaveChanges(); return retrievedShow; }
public Show Post(Show show) { var addedShow = ShowContext.Shows.Add(show); ShowContext.SaveChanges(); return addedShow; }
private List<Show> AddShowtoList(Show showAdd,List<Show> shows) { int Showcount = shows.Count; try { shows.Add( new Show() { Id = Showcount+1, Name = showAdd.Name, Description = showAdd.Description }); return shows; } catch (Exception) { return shows; } }