public void Edit_Test_ValidInput()
        {
            // Arrange
            ReviewViewModel oldReview = CreateReviewFromForm(collection);

            rLogic.PostReview(oldReview);
            oldReview = rLogic.GetReviews().FirstOrDefault();
            FormCollection newCollection = new FormCollection
            {
                { "BreweryID", brewery.BreweryID.ToString() },
                { "UserID", user.UserID.ToString() }
            };

            foreach (var i in collection.AllKeys)
            {
                newCollection.Add(i, collection.GetValue(i).AttemptedValue);
            }
            newCollection.Set("ReviewDescription", "new description");

            // Act
            RedirectToRouteResult result = controller.Edit(oldReview.ReviewID, newCollection) as RedirectToRouteResult;

            // Assert
            ReviewViewModel newReview = rLogic.GetReviews().FirstOrDefault();

            Assert.AreNotEqual(newReview.ReviewDescription, collection["ReviewDescription"]);
        }
Example #2
0
        public IActionResult NewReview(int MovieId, string Title)
        {
            List <Review>   reviews   = _context.GetReviews(MovieId);
            ReviewViewModel ViewModel = new ReviewViewModel
            {
                Reviews           = reviews,
                MovieId           = MovieId,
                MovieTitle        = Title,
                AverageRating     = _context.AverageRating(reviews),
                RatingPercentages = _context.GetRatingPercentages(reviews)
            };

            return(View(ViewModel));
        }
        public void ReviewsCountIsFifty()
        {
            List <HtmlDocument> htmlDocList = ReviewLogic.GetReviews(SettingsLogic.GetURL());
            List <Review>       reviewList  = ReviewLogic.ParseReviews(htmlDocList);

            Assert.IsTrue(reviewList.Count == 50);
        }
Example #4
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Fetching Reviews....");
            List <HtmlDocument> htmlDocList = ReviewLogic.GetReviews(SettingsLogic.GetURL());
            List <Review>       reviews     = ReviewLogic.ParseReviews(htmlDocList);

            ScoreLogic.CalculateScores(reviews);
            ReviewLogic.PrintReviewsToConsole(reviews);

            Console.WriteLine("Press enter to close.");
            Console.ReadLine();
        }
        public void ReviewHtmlIsNotNull()
        {
            List <HtmlDocument> htmlDocList = ReviewLogic.GetReviews(SettingsLogic.GetURL());

            Assert.IsFalse(string.IsNullOrWhiteSpace(htmlDocList[0].Text));
        }
        public void ReviewCountIsFive()
        {
            List <HtmlDocument> htmlDocList = ReviewLogic.GetReviews(SettingsLogic.GetURL());

            Assert.IsTrue(htmlDocList.Count == 5);
        }
        public void BadURLTest()
        {
            List <HtmlDocument> htmlDocList = ReviewLogic.GetReviews("https://google.com/;alksdfj;alsdkj");

            Assert.IsTrue(htmlDocList.Count == 0);
        }
        public void DocListIsNull()
        {
            List <HtmlDocument> htmlDocList = ReviewLogic.GetReviews("");

            Assert.IsNull(htmlDocList);
        }