public void ViewReview_InvalidRestId_Fail() { var viewingUserId = 1; var restaurantID = 1010; var request = ViewRestaurantTests.SetupExpectedRequest(viewingUserId, restaurantID); var expectedReviews = new List <Review>(); var expectedSucessStatus = false; var expectedReviewCount = 0; //act ViewReviewsForRestaurantTransaction tran = new ViewReviewsForRestaurantTransaction(Repo, Log, request); tran.Execute(); //assert AssertReviewsInResponse(expectedReviews, expectedSucessStatus, expectedReviewCount, tran); }
public void ViewReview_ValidRestIdOneReview_Succeed() { //arrange var viewingUserId = 1; var restaurantID = 2; var request = ViewRestaurantTests.SetupExpectedRequest(viewingUserId, restaurantID); var expectedReview = new Review { CreatedBy = 3, ReviewUser = Users[2], UpdatedBy = 3, Comment = "Comment for 2", Rating = 3, PostedDateTime = new DateTime(2016, 10, 16), ReviewNumber = 1, }; var expectedSucessStatus = true; var expectedReviewCount = 1; //act ViewReviewsForRestaurantTransaction tran = new ViewReviewsForRestaurantTransaction(Repo, Log, request); tran.Execute(); //assert var actualdResponse = tran.Response; Assert.AreEqual(expectedSucessStatus, actualdResponse.WasSucessfull, "Invalid execution status"); int actualCount = 0; Review actualReview = null; foreach (var rev in actualdResponse.Reviews) { actualCount++; actualReview = rev; } Assert.AreEqual(expectedReviewCount, actualCount, "unexpected review count"); Assert.AreEqual(expectedReview, actualReview); }
public void ViewReview_ValidRestId2Reviews_Succeed() { var viewingUserId = 1; var restaurantID = 3; var request = ViewRestaurantTests.SetupExpectedRequest(viewingUserId, restaurantID); var expectedReviews = new List <Review> { new Review { CreatedBy = 4, UpdatedBy = 4, Comment = "First Comment for 3", Rating = 3, PostedDateTime = new DateTime(2016, 10, 16), ReviewNumber = 2, ReviewUser = Users[3] }, new Review { CreatedBy = 3, UpdatedBy = 3, Comment = "Second Comment for 3", Rating = 5, PostedDateTime = new DateTime(2016, 10, 10), ReviewNumber = 3, ReviewUser = Users[2] } }; var expectedSucessStatus = true; var expectedReviewCount = 2; //act ViewReviewsForRestaurantTransaction tran = new ViewReviewsForRestaurantTransaction(Repo, Log, request); tran.Execute(); //assert AssertReviewsInResponse(expectedReviews, expectedSucessStatus, expectedReviewCount, tran); }
public void ViewReview_ValidRestId10Reviews_Succeed() { var viewingUserId = 1; var restaurantID = 4; var request = ViewRestaurantTests.SetupExpectedRequest(viewingUserId, restaurantID); var expectedReviews = new List <Review>(); for (var i = 0; i < 10; i++) { var newReview = new Review { CreatedBy = Users[i].Id, UpdatedBy = Users[i].Id, Comment = $"Comment {i} for Restaurant 4", Rating = (i % 5) + 1, PostedDateTime = new DateTime(2016, 09, i + 1), ReviewNumber = 4 + i, ReviewUser = Users[i] }; // 0+1 to 4+1 expectedReviews.Add(newReview); } var expectedSucessStatus = true; var expectedReviewCount = 10; //act ViewReviewsForRestaurantTransaction tran = new ViewReviewsForRestaurantTransaction(Repo, Log, request); tran.Execute(); //assert AssertReviewsInResponse(expectedReviews, expectedSucessStatus, expectedReviewCount, tran); }