public CookerOrderReviewReceived FirstCookerOrderReviewReceived() { var firstCookerOrderReviewReceived = new CookerOrderReviewReceived { CookerOrderReviewReceivedId = 1, CookerId = 1, ClientId = 1, MenuId = 1, OrderId = 1, OverallFeedBackRating = 0, ItemAccuracyRating = 0, CommunicationRating = 0, DeliveryTimeRating = 0, Comment = null, Photo = null, OrderDate = DateTime.Today.Date, //ViewModel OrderItems = (from c in new FakeOrderItems().MyOrderItems where c.OrderId == 1 select c).ToList() }; return firstCookerOrderReviewReceived; }
private void UpdateCookerFeedBack_And_ReviewScore_And_ServiceDetail(CookerOrderReviewReceived cookerOrderReviewReceived) { #region UpdateCookerFeedback //Update CookerFeedback var cookerFeedback = _uow.CookerFeedBackRepository.FindBy(x => x.CookerId == 1).FirstOrDefault(); Debug.Assert(cookerFeedback != null, "cookerFeedback != null"); Assert.AreEqual(2, cookerFeedback.TransactionsCount); Assert.AreEqual(5, cookerFeedback.ReviewScore); Assert.AreEqual((decimal)0.5, cookerFeedback.PositiveReview); cookerFeedback.TransactionsCount += 1; cookerFeedback.ReviewScore = cookerFeedback.ReviewScore + cookerOrderReviewReceived.ItemAccuracyRating + cookerOrderReviewReceived.CommunicationRating + cookerOrderReviewReceived.DeliveryTimeRating; if (cookerOrderReviewReceived.OverallFeedBackRating == (int)RatingCodeType.Values.Positive) { cookerFeedback.PositiveReview = cookerFeedback.PositiveReview + (int)RatingCodeType.Values.Positive; } Assert.AreEqual(3, cookerFeedback.TransactionsCount); Assert.AreEqual(14, cookerFeedback.ReviewScore); Assert.AreEqual((decimal)1.5, cookerFeedback.PositiveReview); #endregion #region UpdateCookerReviewScore //Update CookerReviewScore var cookerReviewScore = _uow.CookerReviewScoreRepository.FindBy(x => x.CookerId == 1).FirstOrDefault(); Debug.Assert(cookerReviewScore != null, "cookerReviewScore != null"); Assert.AreEqual(1, cookerReviewScore.PositiveReview); Assert.AreEqual(0, cookerReviewScore.NegativeReview); Assert.AreEqual(0, cookerReviewScore.NeutralReview); if (cookerOrderReviewReceived.OverallFeedBackRating == (int)RatingCodeType.Values.Positive) { cookerReviewScore.PositiveReview = cookerReviewScore.PositiveReview + 1; } if (cookerOrderReviewReceived.OverallFeedBackRating == (int)RatingCodeType.Values.Negative) { cookerReviewScore.NegativeReview = cookerReviewScore.NegativeReview + 1; } if (cookerOrderReviewReceived.OverallFeedBackRating == (int)RatingCodeType.Values.Neutral) { cookerReviewScore.NeutralReview = cookerReviewScore.NeutralReview + 1; } Assert.AreEqual(2, cookerReviewScore.PositiveReview); Assert.AreEqual(0, cookerReviewScore.NegativeReview); Assert.AreEqual(0, cookerReviewScore.NeutralReview); #endregion #region UpdateCookerServiceDetail //UpdateCookerServiceDetail var cookerReviewServiceDetail = _uow.CookerReviewServiceDetailRepository.FindBy(x => x.CookerId == 1).FirstOrDefault(); Debug.Assert(cookerReviewServiceDetail != null, "CookerReviewServiceDetail != null"); Assert.AreEqual(1, cookerReviewServiceDetail.ItemAccuracyRating); Assert.AreEqual(4, cookerReviewServiceDetail.CommunicationRating); Assert.AreEqual(1, cookerReviewServiceDetail.ItemAccuracyRating); Assert.AreEqual(2, cookerReviewServiceDetail.OverallFeedBackRating); Assert.AreEqual(7, cookerReviewServiceDetail.NumberofRatings); cookerReviewServiceDetail.ItemAccuracyRating = (cookerReviewServiceDetail.ItemAccuracyRating * cookerReviewServiceDetail.NumberofRatings + cookerOrderReviewReceived.ItemAccuracyRating) / (cookerReviewServiceDetail.NumberofRatings + 1); cookerReviewServiceDetail.CommunicationRating = (cookerReviewServiceDetail.CommunicationRating * cookerReviewServiceDetail.NumberofRatings + cookerOrderReviewReceived.CommunicationRating) / (cookerReviewServiceDetail.CommunicationRating + 1); cookerReviewServiceDetail.ItemAccuracyRating = (cookerReviewServiceDetail.DeliveryTimeRating * cookerReviewServiceDetail.NumberofRatings + cookerOrderReviewReceived.DeliveryTimeRating) / (cookerReviewServiceDetail.NumberofRatings + 1); cookerReviewServiceDetail.OverallFeedBackRating = (cookerReviewServiceDetail.OverallFeedBackRating * cookerReviewServiceDetail.NumberofRatings + cookerOrderReviewReceived.OverallFeedBackRating) / (cookerReviewServiceDetail.NumberofRatings + 1); cookerReviewServiceDetail.NumberofRatings += 1; Assert.AreEqual(4, cookerReviewServiceDetail.ItemAccuracyRating); Assert.AreEqual(6, cookerReviewServiceDetail.CommunicationRating); Assert.AreEqual(4, cookerReviewServiceDetail.ItemAccuracyRating); Assert.AreEqual(1, cookerReviewServiceDetail.OverallFeedBackRating); Assert.AreEqual(8, cookerReviewServiceDetail.NumberofRatings); #endregion }
private CookerOrderReviewReceived CookerOrderReviewReceived(OrderSubscriptionItem firstsubscriptionItemForWeek1) { Assert.AreEqual(0, _uow.CookerOrderReviewReceivedRepository.FindBy(x => x.OrderId == firstsubscriptionItemForWeek1.OrderSubscriptionId).Count()); //Cooker Review Received var cookerOrderReviewReceived = new CookerOrderReviewReceived { CookerOrderReviewReceivedId = _uow.CookerOrderReviewReceivedRepository.All.ToList().Max(x => x.CookerOrderReviewReceivedId) + 1, CookerId = firstsubscriptionItemForWeek1.CookerId, ClientId = 1, MenuId = firstsubscriptionItemForWeek1.MenuId, OrderId = firstsubscriptionItemForWeek1.OrderSubscriptionId, OverallFeedBackRating = (int)RatingCodeType.Values.Positive, ItemAccuracyRating = 4, CommunicationRating = 3, DeliveryTimeRating = 2, Comment = null, Photo = null, OrderDate = DateTime.Today.Date, }; _uow.CookerOrderReviewReceivedRepository.Add(cookerOrderReviewReceived); _uow.Save(); Assert.AreEqual(1, _uow.CookerOrderReviewReceivedRepository.FindBy(x => x.OrderId == firstsubscriptionItemForWeek1.OrderSubscriptionId).Count()); return cookerOrderReviewReceived; }