Пример #1
0
        public ActionResult RateMovie(RateMovieCarrier rateMovie)
        {
            var ops = new DVDLibraryOperations();
            ops.AddUserReview(rateMovie.Rating, rateMovie.MovieID, rateMovie.UserID, rateMovie.Note);

            var userRentalsVM = new RentalListViewModel(ops.GetUserOutForRent(rateMovie.UserID));

            return View("UserRentalList", userRentalsVM);
        }
Пример #2
0
        public void AddUserReviewTests(int Rating, int MovieID, int UserID, string NoteDescription, int noteCountAdder)
        {
            var ops = new DVDLibraryOperations();
            var ratingCountBefore = 0;
            var ratingCountAfter = 0;
            var noteCountBefore = 0;
            var noteCountAfter = 0;

            using (SqlConnection cn = new SqlConnection(Settings.ConnectionString))
            {
                ratingCountBefore = cn.Query<RatingModel>("SELECT * FROM MovieRatings").Count();
                noteCountBefore = cn.Query<Note>("SELECT * FROM Notes").Count();
                ops.AddUserReview(Rating, MovieID, UserID, NoteDescription);

                ratingCountAfter = cn.Query<RatingModel>("SELECT * FROM MovieRatings").Count();
                noteCountAfter = cn.Query<Note>("SELECT * FROM Notes").Count();
            }

            // Rating count should increase in both cases
            Assert.AreEqual(ratingCountBefore + 1, ratingCountAfter);

            // Note count should only increase with a valid note.
            Assert.AreEqual(noteCountBefore + noteCountAdder, noteCountAfter);
        }