public void AddReview_validReviewRatingOne_succeed() { #region Add one review Reviews.Add(new Review { Comment = "Comment 1", CreatedBy = 1, PostedDateTime = DateTime.Now.AddDays(-1), Rating = 3, ReviewNumber = 1, //ReviewRestaurant = Restaurants[0], ReviewUser = Users[0], UpdatedBy = 1 }); #endregion //Assign var expectedRating = 1; var expectedPostedDateTime = DateTime.Now; var expectedComment = "rating comment 2"; var expectedRestId = 2; var expectedCreatedById = 2; var expectedUpdatedById = expectedCreatedById; var expectedReviewNumber = 2; var expectedSucessStatus = true; var reqData = new AddReviewRequestModel() { Rating = expectedRating, DateTimePosted = expectedPostedDateTime, Comment = expectedComment, UserId = expectedCreatedById, RestaurantId = expectedRestId }; var expectedResponse = new AddReviewResponseModel() { WasSucessfull = expectedSucessStatus, ReviewNumber = expectedReviewNumber }; //act var sut = new AddReviewTransaction(Repo, Log, reqData); sut.Execute(); var actualResponse = sut.Response; //assert Assert.AreEqual(expectedSucessStatus, actualResponse.WasSucessfull, "Invalid execution status"); Assert.AreEqual(expectedResponse, actualResponse, "Invalid response"); ValidateResponse(expectedResponse, expectedRating, expectedPostedDateTime, expectedComment, expectedCreatedById, expectedUpdatedById, expectedReviewNumber); }
private void ValidateResponse(AddReviewResponseModel expectedResponse, int expectedRating, DateTime expectedPostedDateTime, string expectedComment, int expectedCreatedById, int expectedUpdatedById, int expectedReviewNumber) { var actualReview = Reviews[expectedResponse.ReviewNumber - 1]; Assert.AreEqual(expectedRating, actualReview.Rating, "Rating"); Assert.AreEqual(expectedPostedDateTime, actualReview.PostedDateTime, "Posted Time"); Assert.AreEqual(expectedComment, actualReview.Comment, "Comment"); Assert.AreEqual(expectedCreatedById, actualReview.CreatedBy, "Created by"); Assert.AreEqual(expectedUpdatedById, actualReview.UpdatedBy, "Updated by"); Assert.AreEqual(expectedReviewNumber, actualReview.ReviewNumber, "Review Number"); //Assert.AreEqual(expectedRestId, actualReview.ReviewRestaurant.Id, "Restaurant Id"); Assert.AreEqual(expectedCreatedById, actualReview.ReviewUser.Id, "User Id"); }
public void AddReview_RaitingTooHigh_Fail() { AddTwoReviews(); //Assign var expectedRating = 9; var expectedPostedDateTime = DateTime.Now; var expectedComment = "rating comment 9"; var expectedRestId = 2; var expectedCreatedById = 3; var expectedReviewNumber = 0; var expectedSucessStatus = false; var reqData = new AddReviewRequestModel() { Rating = expectedRating, DateTimePosted = expectedPostedDateTime, Comment = expectedComment, UserId = expectedCreatedById, RestaurantId = expectedRestId }; var expectedResponse = new AddReviewResponseModel() { WasSucessfull = expectedSucessStatus, ReviewNumber = expectedReviewNumber }; //act var sut = new AddReviewTransaction(Repo, Log, reqData); sut.Execute(); var actualResponse = sut.Response; //assert Assert.AreEqual(expectedSucessStatus, actualResponse.WasSucessfull, "Invalid execution status"); Assert.AreEqual(expectedResponse, actualResponse, "Invalid response"); var noneAddreReview = Reviews.Find(r => r.ReviewNumber == expectedReviewNumber); Assert.IsNull(noneAddreReview); }
public void AddReview_vlaidReviewRatingFive_succeed() { AddTwoReviews(); //Assign var expectedRating = 5; var expectedPostedDateTime = DateTime.Now; var expectedComment = "rating comment 5"; var expectedRestId = 2; var expectedCreatedById = 3; var expectedUpdatedById = expectedCreatedById; var expectedReviewNumber = 3; var expectedSucessStatus = true; var reqData = new AddReviewRequestModel() { Rating = expectedRating, DateTimePosted = expectedPostedDateTime, Comment = expectedComment, UserId = expectedCreatedById, RestaurantId = expectedRestId }; var expectedResponse = new AddReviewResponseModel() { WasSucessfull = expectedSucessStatus, ReviewNumber = expectedReviewNumber }; //act var sut = new AddReviewTransaction(Repo, Log, reqData); sut.Execute(); var actualResponse = sut.Response; //assert Assert.AreEqual(expectedSucessStatus, actualResponse.WasSucessfull, "Invalid execution status"); Assert.AreEqual(expectedResponse, actualResponse, "Invalid response"); ValidateResponse(expectedResponse, expectedRating, expectedPostedDateTime, expectedComment, expectedCreatedById, expectedUpdatedById, expectedReviewNumber); }