public void ResultsShouldReturnReturnOrderedQuotesWithoutNonZeroQuotes() { DeleteQuotes(); QuoteMovie quote0 = TestUtil.generateQuoteMovie(); quote0.QuoteString = "Ranking 0 bla bla"; quote0.Ranking = 0; AddQuote(quote0); QuoteBook quote1 = TestUtil.generateQuoteBook(); quote1.QuoteString = "bla bla Ranking 1 bla bla"; quote1.Ranking = 1; AddQuote(quote1); QuoteTV_Show quote2 = TestUtil.generateQuoteTV_Show(); quote2.QuoteString = "bla Ranking 2 bla bla"; quote2.Ranking = 2; AddQuote(quote2); QuoteBook quote3 = TestUtil.generateQuoteBook(); quote3.QuoteString = "Ranking 3"; quote3.Ranking = 3; AddQuote(quote3); SearchController searchController = new SearchController(); FormCollection collection = new FormCollection(); collection["TextBoxSearch"] = "Ranking"; ViewResult result = searchController.Results(collection) as ViewResult; Assert.IsNotNull(result); IEnumerable <Quote> model = result.ViewData.Model as IEnumerable <Quote>; Assert.IsNotNull(model); Assert.AreEqual(3, model.Count <Quote>()); int i = 1; foreach (Quote quote in model) { Assert.AreEqual(i++, quote.Ranking); Assert.IsTrue(quote.QuoteString.Contains("Ranking")); } Assert.AreEqual(resultQuotesView, result.ViewName); }
public static QuoteMovie generateQuoteMovie() { QuoteMovie quoteMovie = new QuoteMovie(); quoteMovie.QuoteString = "quoteString"; quoteMovie.Language = "English"; quoteMovie.Character = "T-1000"; quoteMovie.Ranking = 1; Movie movie = generateMovie(); quoteMovie.Movie = movie; quoteMovie.Media = movie; return(quoteMovie); }
public ActionResult AddQuote(int id, FormCollection collection, IPrincipal iuser) { User user = MembershipDao.Instance.GetCurrentUser(iuser.Identity.Name); Book book = MediaService.Instance.GetBookById(id); if (book != null) { QuoteBook quoteBook = new QuoteBook(); quoteBook.Language = collection["Language"]; quoteBook.Character = collection["Character"]; quoteBook.QuoteString = collection["QuoteString"]; quoteBook.MediaId = id; quoteBook.UserId = user.Id; quoteBook.Book = book; quoteService.AddQuote(quoteBook); } Movie movie = MediaService.Instance.GetMovieById(id); if (movie != null) { QuoteMovie quoteMovie = new QuoteMovie(); quoteMovie.Language = collection["Language"]; quoteMovie.Character = collection["Character"]; quoteMovie.OccurenceTime = collection["Wann"]; quoteMovie.QuoteString = collection["QuoteString"]; quoteMovie.MediaId = id; quoteMovie.UserId = user.Id; quoteMovie.Movie = movie; quoteService.AddQuote(quoteMovie); } TV_Show tvshow = MediaService.Instance.GetTvShowById(id); if (tvshow != null) { QuoteTV_Show quoteTVShow = new QuoteTV_Show(); quoteTVShow.Language = collection["Language"]; quoteTVShow.Character = collection["Character"]; quoteTVShow.OccurenceTime = collection["Wann"]; quoteTVShow.QuoteString = collection["QuoteString"]; quoteTVShow.MediaId = id; quoteTVShow.UserId = user.Id; Season season = MediaService.Instance.GetSeasonById(tvshow.Season.ElementAt <Season>(0).Id); Episode episode = new Episode(); episode.Name = season.Episode.ElementAt <Episode>(0).Name; episode.Number = season.Episode.ElementAt <Episode>(0).Number; episode.Season = season; quoteTVShow.Episode = episode; quoteService.AddQuote(quoteTVShow); } //return View("ShowQuotesMedia", quotes); //return RedirectToAction("ShowQuotesMedia", "Quote", new { mediaId = id }); return(View("AddQuoteMessage")); }