예제 #1
0
 public void TestAverageScores()
 {
     Review review = new UserReview("name", "content", DateTime.Now, "spoiler", 10, 1);
     List<int> scores = new List<int>();
     scores.Add(100);
     scores.Add(50);
     int actual = review.AverageScore(scores);
     Assert.AreEqual(75, actual, "Check average score");
 }
예제 #2
0
 public void TestGetReviews()
 {
     List<Review> reviews = new List<Review>();
     MetaReview meta = new MetaReview("name", "content", DateTime.Now, "spoiler", 10);
     reviews = meta.getMetaReviews(1);
     Assert.AreEqual(4, reviews.Count, "Count list items"); // gets all reviews with category 2 (games)
     List<Review> userReviews = new List<Review>();
     UserReview user = new UserReview("name", "content", DateTime.Now, "spoiler", 10, 1);
     userReviews = user.getUserReviews(1);
     Assert.AreEqual(4, userReviews.Count);
 }
예제 #3
0
        /// <summary>
        /// returns all userreviews with a given categorienumber
        /// </summary>
        /// <param name="categorienr">1=game, 2=movie, 3=show, 4=music</param>
        /// <returns></returns>
        public List<Review> getUserReviews(int categorienr)
        {
            List<Review> userReviews = new List<Review>(); 
            string name = "";
            int score = 0;
            string text = "";
            DateTime date = DateTime.Today;
            string spoiler = "";

            foreach (Dictionary<string, object> D in db.getReviews(categorienr))
            {
                name = (string)D["naam"];
                score = Convert.ToInt32(D["score"]);
                text = (string) D["inhoud"];
                date = (DateTime) D["datum"];
                spoiler = (string) D["spoiler"];
                Review review = new UserReview(name, text, date, spoiler, score, 1);
                userReviews.Add(review);
            }
            return userReviews;
        }