예제 #1
0
        public void CreateReview()
        {
            var review = new Review { Id = 1, Title = "This Film is Awesome", Content = "Thrilling plot twists and brilliant acting", Score = 5 };

            Assert.AreEqual(review.Id, 1);
            Assert.AreEqual(review.Title, "This Film is Awesome");
            Assert.AreEqual(review.Content, "Thrilling plot twists and brilliant acting");
            Assert.AreEqual(review.Score, 5);
        }
예제 #2
0
        /// <summary>
        /// Saves the reviews.
        /// </summary>
        /// <param name="review">The review.</param>
        public void SaveReviewAsync(Review review)
        {
            if (context.Reviews.Count(r => r.Id == review.Id) != 0)
            {
                context.Reviews.Single(r => r.Id == review.Id).Update(review);
            }
            else
            {
                context.Reviews.Add(review);
            }

            context.SaveChangesAsync();
        }
예제 #3
0
        public void UpdateReview()
        {
            Review newReview = new Review();

            newReview.Title = "Updated Title";

            Reviews.FirstOrDefault(r => r.Id == 1).Update(newReview);
            Review review = Reviews.FirstOrDefault(r => r.Id == 1);

            Assert.AreNotEqual(review.Title, "Testing");
            Assert.AreEqual(review.Title, "Updated Title");
            
        }
예제 #4
0
        public void Setup()
        {
            var reviews = new List<Review>();
               
            var review = new Review();
            review.Id = 1;
            review.Title = "Testing";
            review.Content = "Testng Reviews";
            review.UserId = "d9274a62-8a8c-46bf-aedc-d1cb3e8626c0";
            review.Username = "******";

            reviews.Add(review);

            this.Reviews = reviews.ToList();
        }
예제 #5
0
 /// <summary>
 /// Deletes the review.
 /// </summary>
 /// <param name="review">The review.</param>
 public void DeleteReviewAsync(Review review)
 {
     context.Reviews.Remove(review);
     context.SaveChangesAsync();
 }
예제 #6
0
        /// <summary>
        /// Updates the specified review.
        /// </summary>
        /// <param name="review">The review.</param>
        public void Update(Review review)
        {
            this.ExternalId = review.ExternalId;
            this.Title = review.Title;
            this.content = review.content;
            this.Score = review.Score;
            this.UserId = review.UserId;

            this.Modified = DateTime.Now;
        }