public void CountPropertyOk() { clsLinkCollection AllLinks = new clsLinkCollection(); Int32 someCount = 9753; AllLinks.Count = someCount; Assert.AreEqual(AllLinks.Count, someCount); }
public void ImdbIdAlreadyExistsCheckMethodOk() { clsLinkCollection AllLinks = new clsLinkCollection(); bool exists; Int32 imdbId = 0114709; exists = AllLinks.ImdbIdAlreadyExistsCheck(imdbId); Assert.IsTrue(exists); }
public void ThisLinkPropertyOk() { clsLinkCollection Links = new clsLinkCollection(); clsLink aLink = new clsLink(); aLink.FilmId = 1; aLink.ImdbId = 0114709; Links.ThisLink = aLink; Assert.AreEqual(Links.ThisLink, aLink); }
public void AddMethodOk() { clsLinkCollection AllLinks = new clsLinkCollection(); clsLink TestItem = new clsLink(); TestItem.FilmId = 193610; TestItem.ImdbId = 1160419; AllLinks.ThisLink = TestItem; AllLinks.Add(); AllLinks.ThisLink.Find(TestItem.FilmId); Assert.AreEqual(AllLinks.ThisLink, TestItem); }
public void CountMatchesList() { clsLinkCollection Links = new clsLinkCollection(); List <clsLink> testList = new List <clsLink>(); clsLink testItem = new clsLink(); testItem.FilmId = 1; testItem.ImdbId = 00000; testList.Add(testItem); Links.AllLinks = testList; Assert.AreEqual(Links.Count, testList.Count); }
public void UpdateMethodOk() { clsLinkCollection AllLinks = new clsLinkCollection(); clsLink TestItem = new clsLink(); TestItem.FilmId = 193615; TestItem.ImdbId = 1111111; AllLinks.ThisLink = TestItem; AllLinks.Add(); TestItem.ImdbId = 5034838; AllLinks.ThisLink = TestItem; AllLinks.Update(); AllLinks.ThisLink.Find(TestItem.FilmId); Assert.AreEqual(AllLinks.ThisLink, TestItem); }
public void GetLinkByFilmIdMethodOk() { bool imdbIdExists = false; clsLinkCollection AllLinks = new clsLinkCollection(); AllLinks.ThisLink.FilmId = 256; AllLinks.GetLinkByFilmId(); string imdbId = AllLinks.ThisLink.ImdbId.ToString(); if (imdbId.Length != 0) { imdbIdExists = true; } else { } Assert.IsTrue(imdbIdExists); }
public Panel GetImdbInformation(Int32 filmId) { clsLinkCollection AllLinks = new clsLinkCollection(); AllLinks.ThisLink.FilmId = filmId; AllLinks.GetLinkByFilmId(); string imdbId = AllLinks.ThisLink.ImdbId.ToString(); var client = new RestClient("https://movie-database-imdb-alternative.p.rapidapi.com/?i=" + imdbId); var request = new RestRequest(Method.GET); request.AddHeader("x-rapidapi-key", ConfigurationManager.AppSettings["RapidApiKey"]); request.AddHeader("x-rapidapi-host", "movie-database-imdb-alternative.p.rapidapi.com"); IRestResponse response = client.Execute(request); clsImdbAPI filmInfoReturned = new clsImdbAPI(); filmInfoReturned = Newtonsoft.Json.JsonConvert.DeserializeObject <clsImdbAPI>(response.Content); var imdbIdOk = filmInfoReturned.Response; Int32 count = 0; string numberOfZeroes = "0"; string newImdbId = "tt"; //this part is inefficient - needs looking at while (imdbIdOk == false) { newImdbId = newImdbId + numberOfZeroes.PadRight(count, '0') + imdbId; //may need the below if the search fails newImdbId = "tt" + numberOfZeroes.PadRight(count, '0') + imdbId; //newImdbId = newImdbId.Replace(" ", string.Empty); client = new RestClient("https://movie-database-imdb-alternative.p.rapidapi.com/?i=" + newImdbId); request = new RestRequest(Method.GET); request.AddHeader("x-rapidapi-key", ConfigurationManager.AppSettings["RapidApiKey"]); request.AddHeader("x-rapidapi-host", "movie-database-imdb-alternative.p.rapidapi.com"); response = client.Execute(request); filmInfoReturned = new clsImdbAPI(); filmInfoReturned = Newtonsoft.Json.JsonConvert.DeserializeObject <clsImdbAPI>(response.Content); imdbIdOk = filmInfoReturned.Response; count++; } Panel pnlFilm = new Panel(); pnlFilm.CssClass = "filmWithTextContainer"; ImageButton newClickableImage = new ImageButton(); newClickableImage.CssClass = "image"; newClickableImage.ImageUrl = filmInfoReturned.Poster; newClickableImage.PostBackUrl = "FilmInformation.aspx?FilmId=" + filmId + "&ImdbId=" + newImdbId; Panel pnlFilmTitle = new Panel(); pnlFilmTitle.CssClass = "titleContainer"; Label lblFilmTitle = new Label(); lblFilmTitle.Text = filmInfoReturned.Title; pnlFilmTitle.Controls.Add(lblFilmTitle); pnlFilm.Controls.Add(newClickableImage); pnlFilm.Controls.Add(pnlFilmTitle); return(pnlFilm); }
public void InstanceOk() { clsLinkCollection AllLinks = new clsLinkCollection(); Assert.IsNotNull(AllLinks); }
protected void btnActionFilm_Click(object sender, EventArgs e) { string originalTitle = ""; editFilm = Convert.ToBoolean(Session["EditFilm"]); if (editFilm) { originalTitle = Session["Title"].ToString(); } string newTitle = txtFilmTitle.Text; string tempImdbId = txtImdbId.Text; Int32 imdbId = 0; bool imdbIdOk = false; clsFilm aFilm = new clsFilm(); var filmTitleCheck = aFilm.Valid(newTitle); if (filmTitleCheck.Count != 0) { foreach (string error in filmTitleCheck) { Label lblError = new Label(); lblError.Text = "- " + error; pnlActionFilmErrorBody.Controls.Add(lblError); pnlActionFilmErrorBody.Controls.Add(new LiteralControl("<br />")); } } clsLinkCollection AllLinks = new clsLinkCollection(); var imdbIdCheck = AllLinks.ThisLink.Valid(tempImdbId); if (imdbIdCheck.Count != 0) { foreach (string error in imdbIdCheck) { Label lblError = new Label(); lblError.Text = "- " + error; pnlActionFilmErrorBody.Controls.Add(lblError); pnlActionFilmErrorBody.Controls.Add(new LiteralControl("<br />")); imdbIdOk = false; } pnlActionFilmError.Visible = true; } else { imdbId = Convert.ToInt32(tempImdbId); bool ImdbIdAlreadyExists = AllLinks.ImdbIdAlreadyExistsCheck(imdbId); if (ImdbIdAlreadyExists) { //if (!editFilm) //adding a new film //{ Label lblError = new Label(); lblError.Text = "- IMDBId already assigned to another film"; pnlActionFilmErrorBody.Controls.Add(lblError); pnlActionFilmErrorBody.Controls.Add(new LiteralControl("<br />")); pnlActionFilmError.Visible = true; imdbIdOk = false; //} Int32 originalImdbId = Convert.ToInt32(Session["originalIMDBId"]); if (originalImdbId == imdbId) { imdbIdOk = true; } else { imdbIdOk = false; } //else //if we're editing a film //{ // Int32 originalImdbId = Convert.ToInt32(Session["originalIMDBId"]); // if (originalImdbId != imdbId) // { // Label lblError = new Label(); // lblError.Text = "- IMDBId already assigned to another film"; // pnlActionFilmErrorBody.Controls.Add(lblError); // pnlActionFilmErrorBody.Controls.Add(new LiteralControl("<br />")); // imdbIdOk = false; // } // else // { // imdbIdOk = true; // } //} } else { imdbIdOk = true; } } newTitle = newTitle.TrimEnd(); string yearReleased = " " + "(" + ddlYear.SelectedValue + ")"; string titleAndYearReleased = newTitle + yearReleased; bool filmAlreadyExists = false; clsFilmCollection AllFilms = new clsFilmCollection(); if (AllFilms.FilmAlreadyExistsCheck(titleAndYearReleased)) { if (!editFilm) { Label lblError = new Label(); lblError.Text = "Film already exists"; pnlActionFilmErrorBody.Controls.Add(lblError); filmAlreadyExists = true; } else //if we ARE editing a film { if (newTitle != originalTitle) { Label lblError = new Label(); lblError.Text = "Film already exists"; pnlActionFilmErrorBody.Controls.Add(lblError); filmAlreadyExists = true; } else { filmAlreadyExists = false; } } } else { filmAlreadyExists = false; } if (!editFilm && !filmAlreadyExists && imdbIdOk) { AllFilms = new clsFilmCollection(); AllFilms.ThisFilm.Title = titleAndYearReleased; Int32 filmId = AllFilms.Add(); AllLinks.ThisLink.FilmId = filmId; AllLinks.ThisLink.ImdbId = imdbId; AllLinks.Add(); clsFilmGenreCollection AllFilmGenres = new clsFilmGenreCollection(); foreach (ListItem item in chkbxlstGenres.Items) { if (item.Selected) { AllFilmGenres.ThisFilmGenre.FilmId = filmId; AllFilmGenres.ThisFilmGenre.GenreId = Convert.ToInt32(item.Value); AllFilmGenres.Add(); AllFilmGenres = new clsFilmGenreCollection(); } } LoadData(); pnlActionFilm.Visible = false; } if (editFilm) { AllFilms = new clsFilmCollection(); AllFilms.ThisFilm.FilmId = Convert.ToInt32(Session["FilmId"]); newTitle = titleAndYearReleased; if (newTitle == originalTitle) { AllFilms.ThisFilm.Title = originalTitle; } else { AllFilms.ThisFilm.Title = newTitle; } AllFilms.Update(); clsFilmGenreCollection AllFilmGenres = new clsFilmGenreCollection(); AllFilmGenres.ThisFilmGenre.FilmId = filmId; AllFilmGenres.DeleteByFilmId(); foreach (ListItem item in chkbxlstGenres.Items) { if (item.Selected) { AllFilmGenres.ThisFilmGenre.FilmId = filmId; AllFilmGenres.ThisFilmGenre.GenreId = Convert.ToInt32(item.Value); AllFilmGenres.Add(); AllFilmGenres = new clsFilmGenreCollection(); } } LoadData(); pnlActionFilm.Visible = false; } }