public void FindRatingFromMovieID_FindsRatingCorrespondingToMovieId_PassesIfRatingIsNotFound(int movieId)
        {
            new User("NUnitTest");
            string movieRating = MySqlCommands.FindRatingFromMovieId(movieId);

            Assert.AreEqual("notRated", movieRating);
        }
        public void FindMovieFromID_FindsMoviesCorrespondingToMovieId_PassesIfAllMoviesNotAreFound(params int[] id)
        {
            List <int>           movieIds    = new List <int>(id);
            List <MovieMenuItem> foundMovies = MySqlCommands.FindMovieFromId(movieIds);

            Assert.AreNotEqual(movieIds.Count, foundMovies.Count);
        }
        public void GetMovies_FindsAllMoviesInDatabase_PassesIfAllMoviesAreFound()
        {
            int numberOfMovies          = MySqlCommands.NumberOfRowsInTable("imdbdata");
            List <MovieMenuItem> movies = MySqlCommands.GetMovies();

            Assert.AreEqual(numberOfMovies, movies.Count);
        }
        public void GetUserRatedMovies_SelectMoviesFromUsersTable_PassesIfGetsAllMovies()
        {
            new User("NUnitTest");
            int numberOfMoviesInTable = MySqlCommands.NumberOfRowsInTable("NUnitTest_movies");

            Assert.AreEqual(numberOfMoviesInTable, MySqlCommands.GetUserRatedMovies().Count);
        }
        public void GetRecommendedMovies_testuser_StarWarsRecommended()
        {
            new User("testuser");
            MySqlCommands.RateMovie(12, "thumbsup");  // star wars movie
            MySqlCommands.RateMovie(212, "thumbsup"); // star wars movie
            MySqlCommands.RateMovie(73, "thumbsup");  // star wars movie
            MySqlCommands.RateMovie(10, "thumbsup");  // fight club
            MySqlCommands.RateMovie(13, "thumbsup");  // forrest gump
            MySqlCommands.RateMovie(22, "thumbsup");  // se7en

            Recommender.Update("genre", "directors", "actors");
            Recommender.AlgorithmMovieWeight(MySqlCommands.FindMovieFromId(new List <int> {
                20
            }).ToList());
            // given user data with these 6 movies for the movieid 20, Star Wars(1997)
            // genre: action(0,5), adventure(0,5), fantasy(0,5), sci-fi(0,5)
            // director: george lucas(0)
            // actors: Mark(0,5), Harrison(0,5), Carrie(0,5), Peter C(0), Alec(0,1667), Anthony(0,3333), Kenny(0,1667), Peter M(0,3333), David(0,1667), Phil(0)

            // total director = 0
            // total actors = 0,5 + 0,5 + 0,5 + 0 + 0,1667 + 0,3333 + 0,1667 + 0,3333 + 0,1667 + 0 = 2,6667
            // total genre = 0,5 + 0,5/4 + 0,5/4 + 0,5/4 = 0,875

            // total weight = 0 + 2,6667 + 0,875 = 3,5417

            KeyValuePair <MovieMenuItem, double> movie = Recommender.MovieRatingsWeight.First();

            Assert.AreEqual(Math.Round(3.5417, 2), (Math.Round(movie.Value, 2))); // rounds down due to data is more preceise
        }
        [TestCase("actors", "Harrison Ford", ExpectedResult = 0.33)] // 1/3/1/1 = 0,33
        public double Update_TestUserPreferences(string type, string item)
        {
            new User("testuserPreferences");
            MySqlCommands.RateMovie(12, "thumbsup"); // star wars movie
            MySqlCommands.RateMovie(13, "thumbsup"); // forrest gump
            MySqlCommands.RateMovie(10, "thumbsup"); // fight club
            Recommender.Update(type);

            return(Math.Round(User.Preferences[type][item][(int)UserRating.Weight], 2));
        }
Example #7
0
 public ClientAdapter(MySqlCommands mysql)
 {
     _mysql = mysql;
 }
        public bool IsMovieRated_ChecksIfMoviesAreRated_ReturnsTrueIfMovieIsRated(int movieId)
        {
            new User("NUnitTest");

            return(MySqlCommands.IsMovieRated(movieId));
        }
        public bool RateMovie_ChecksIfMovieGetsRated_ReturnsTrueIfMovieIsRated(int movieId, string enumvalue)
        {
            new User("NUnitTest");

            return(MySqlCommands.RateMovie(movieId, enumvalue));
        }
 public bool UsernameExists_ChecksIfUsernameExists_ReturnsStateIfUsernameExists(string username)
 {
     return(MySqlCommands.UserExist(username));
 }
 public bool Login_ReceiveUsernameAndPasssword_returnsState(string username, string password)
 {
     return(MySqlCommands.FindUser(username, password));
 }