public void TestMergeTwoOmdbEntryLists() { //create a imdb OE OmdbEntry imdb_omdbentry = new OmdbEntry { i_ID = "asd", i_Rating = "asd", i_Votes = "123" }; List <OmdbEntry> imdb_list = new List <OmdbEntry> { imdb_omdbentry }; //create a RT OE OmdbEntry rt_omdbentry = new OmdbEntry { t_Consensus = "rotten", t_Fresh = 123, t_Image = "asddd", t_Meter = 123, t_Reviews = 12355, t_Rotten = 333, t_UserMeter = 233, t_UserReviews = 3 }; List <OmdbEntry> rt_list = new List <OmdbEntry> { rt_omdbentry }; //expected OE result OmdbEntry expected_omdbentry = new OmdbEntry { i_ID = "asd", i_Rating = "asd", i_Votes = "123", t_Consensus = "rotten", t_Fresh = 123, t_Image = "asddd", t_Meter = 123, t_Reviews = 12355, t_Rotten = 333, t_UserMeter = 233, t_UserReviews = 3 }; List <OmdbEntry> res = TSVParse.MergeTwoOmdbEntryLists(imdb_list, rt_list); OmdbEntry resulting_omdbentry = res[0]; Assert.AreEqual(expected_omdbentry, resulting_omdbentry); Assert.AreNotEqual(new OmdbEntry(), resulting_omdbentry); }
public void TestMatchMovieIdToOmdbEntry() { MovieDbContext db = new MovieDbContext(); //Tools.TraceLine(db.Database.Connection.ConnectionString); int first_movie_id = db.Movies.First().movie_ID; OmdbEntry expected_omdbentry = db.Omdb.First(omdb => omdb.movie_ID == first_movie_id); OmdbEntry result = Tools.MatchMovieIdToOmdbEntry(first_movie_id); Assert.AreEqual(expected_omdbentry, result); }
public static IQueryable <FullViewModel> CreateFullView(IQueryable <Movie> movies, MovieDbContext db) { // var db = new MovieDbContext(); var movieID_genreString_grouping = from mtg in db.MovieToGenres join genre in db.Genres on mtg.genre_ID equals genre.genre_ID group genre.genre_string by mtg.movie_ID; //a default empty element OmdbEntry defaultOmdbEntry = new OmdbEntry { }; var nitvmQuery = //left outer join so that all movies get selected even if there's no omdb match from movie in movies join omdb in db.Omdb on movie.movie_ID equals omdb.movie_ID into mov_omdb_matches from mov_omdb_match in mov_omdb_matches.DefaultIfEmpty() //match the boxarts from boxart in db.BoxArts where movie.movie_ID == boxart.movie_ID //match the genres string from grp in movieID_genreString_grouping where grp.Key == movie.movie_ID //match the genre id //create the NITVM select new FullViewModel { Movie = movie, Boxarts = boxart, Genres = grp, Genre_IDs = (List <int>)(from mtg in db.MovieToGenres where mtg.movie_ID == movie.movie_ID select mtg.genre_ID), //OmdbEntry = (mov_omdb_match == null) ? mov_omdb_match.movie_ID= movie.movie_ID: mov_omdb_match OmdbEntry = mov_omdb_match }; return(nitvmQuery); }
public static OmdbEntry Omdb(int movieID) { MovieDbContext db = new MovieDbContext(); OmdbEntry omdb = new OmdbEntry(); omdb = Tools.MatchMovieIdToOmdbEntry(movieID); return(omdb); /* for posterity in case Tools.Cs changes * public static OmdbEntry MatchMovieIdToOmdbEntry(int movie_ID) * { * MovieDbContext db = new MovieDbContext(); * var omdbEntry = db.Omdb.FirstOrDefault(omdb => omdb.movie_ID == movie_ID); * * return omdbEntry; * }*/ }
public void TestUpdateImdbEntryWithRtEntry() { var imdb_param = new OmdbEntry(); var rt_param = new OmdbEntry { t_Consensus = "asd", t_Fresh = 123, t_Image = "asd", t_Meter = 123, t_Rating = 1.2f, t_Reviews = 123, t_Rotten = 123, t_UserMeter = 1234, t_UserRating = 12.4f, t_UserReviews = 12345 }; TSVParse.UpdateImdbEntryWithRtEntry(imdb_param, rt_param); OmdbEntry expected = new OmdbEntry { t_Consensus = "asd", t_Fresh = 123, t_Image = "asd", t_Meter = 123, t_Rating = 1.2f, t_Reviews = 123, t_Rotten = 123, t_UserMeter = 1234, t_UserRating = 12.4f, t_UserReviews = 12345 }; Assert.AreEqual(imdb_param, expected); Assert.AreNotEqual(imdb_param, new OmdbEntry()); }
public void TestOmdbEquals() { OmdbEntry first_movie = new OmdbEntry { //ignore because I'm not sure when a movie_id will or wont be set //movie_ID = , title = "movie called", year = 1999, i_Rating = "asd", i_Votes = "400", i_ID = "asd", t_Meter = 2, t_Image = "asd", //ignore cause of float //t_Rating = 22, t_Reviews = 123, t_Fresh = 23, t_Rotten = 23, t_Consensus = "rotten", t_UserMeter = 233, //ignore cause of float //t_UserRating = 2.4f, t_UserReviews = 232, }; OmdbEntry second_movie = new OmdbEntry { //ignore because I'm not sure when a movie_id will or wont be set //movie_ID = , title = "movie called", year = 1999, i_Rating = "asd", i_Votes = "400", i_ID = "asd", t_Meter = 2, t_Image = "asd", //ignore cause of float //t_Rating = 22, t_Reviews = 123, t_Fresh = 23, t_Rotten = 23, t_Consensus = "rotten", t_UserMeter = 233, //ignore cause of float //t_UserRating = 2.4f, t_UserReviews = 232, }; //{ // year = 1999, // i_ID = "200", // i_Votes = "12345" //}; Assert.AreEqual(first_movie, second_movie); OmdbEntry bogus_movie = new OmdbEntry { t_Consensus = "asd", }; Assert.AreNotEqual(first_movie, bogus_movie); Assert.AreNotEqual(second_movie, bogus_movie); }