public void ReviewRepository_AddTwoWithSameKeys_ThrowsException() { var review = new Review() { BarName = "Katrines Kælder", Username = "******", BarPressure = 3, }; _uut.Add(review); Assert.That(() => _context.SaveChanges(), Throws.Exception); }
public void TestgetRejectedProposalsIds() { reviewRepository.Add(review); Assert.AreEqual(1, reviewRepository.getRejectedProposalsIds().Count); reviewRepository.Delete(review); proposalRepository.Delete(proposal); }
public void GetReviewByReserveIdTest() { ContextObl context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); IReviewRepository reviewRepo = new ReviewRepository(context); ITouristSpotRepository touristSpotRepo = new TouristSpotRepository(context); ILodgingRepository lodgingRepo = new LodgingRepository(context); IRepository <Reserve> reserveRepo = new BaseRepository <Reserve>(context); touristSpotRepo.Add(touristSpot); lodgingRepo.Add(lodging); reserveRepo.Add(reserve); Review reviewToAdd = new Review() { Id = Guid.NewGuid(), Description = "Me gusto mucho la estadia", IdOfReserve = reserve.Id, LastNameOfWhoComments = reserve.LastName, NameOfWhoComments = reserve.Name, LodgingOfReview = lodging, Score = 4 }; reviewRepo.Add(reviewToAdd); Review reviewResult = reviewRepo.GetReviewByReserveId(reserve.Id); Assert.IsTrue(reviewResult.Equals(reviewToAdd)); }
private void AddReviewRecordsForTest() { using (var context = new CMMIContext()) { repository = new ReviewRepository(context); repository.Add(review); context.SaveChanges(); currentReview = repository.GetReviewsByRestaurantId(currentRestaurant.RestaurantId).FirstOrDefault(); } }
public ActionResult Adauga(ReviewModel opinie1) { if (ModelState.IsValid) { ReviewRepository r = new ReviewRepository(); r.Add(opinie1); return(RedirectToAction("Index")); } return(View(opinie1)); }
public ActionResult Create(int id, Review review) { if (ModelState.IsValid) { review.Date = DateTime.Now; review.CustomerId = User.Identity.GetUserId(); review.ProductId = id; reviewRepository.Add(review); return(RedirectToAction("Details", "Product", new { id = review.ProductId })); } return(View()); }
public void AddTest() { using (var context = new CMMIContext()) { repository = new ReviewRepository(context); repository.Add(review); repository.Save(); var result = repository.GetReviewsByRestaurantId(currentReview.RestaurantId).ToList(); Assert.AreEqual(result.Count, 2); repository.Remove(result.First().ReviewId); currentReview = result.Last(); } }
public void Add_GivenReview_AddsReview() { var review = new Review { ReviewId = Guid.NewGuid(), ReviewPublicId = Guid.NewGuid(), Restaurant = _testContext.Restaurants.First() }; _reviewRepository.Add(review); var reviews = _testContext.Reviews.ToList(); Assert.IsTrue(reviews.Contains(review)); }
private void btnOk_Click(object sender, RoutedEventArgs e) { if (txtDescription.Text.Length > 0) { UpdateReview(_review); if (_isNew) { _reviewRepo.Add(_review); } this.Close(); } else { MessageBox.Show("Please input description.", Utils.AssemblyTitle); } }
public void PostReview(ReviewDTO reviewdto, string username, int Id) { var reviewedUserId = (from t in _tripRepo.List() where t.Id == Id from u in t.UserTrips select u).FirstOrDefault().UserId; var blah = reviewedUserId; var reviews = _repo.List().Where(r => r.User.Id == reviewedUserId).Select(r => r); var review = new Review { Rating = (reviews.Sum(x => x.Rating) + reviewdto.Rating) / (reviews.Count() + 1), Comment = reviewdto.Comment, //Username = reviewdto.Username, UserId = reviewedUserId }; _repo.Add(review); _repo.SaveChanges(); }
public ActionResult Create(ReviewsCreateVM vm) { try { if (ModelState.IsValid) // server-side validation { reviewRepository.Add(vm.Review); return(RedirectToAction("Index")); } else { return(View(ModelState)); } } catch (Exception e) { log.Error($"[Reviews Controller] [Create] Exception thrown: {e.Message}"); return(View()); } }
/// <summary> /// Handles the Click event of the tbtnAdd control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void tbtnAdd_Click(object sender, EventArgs e) { try { if (VisualStudioInstance.Solution.IsOpen) { var test = VisualStudioInstance; TextSelection textSelection = (TextSelection)VisualStudioInstance.ActiveDocument.Selection; int line = textSelection.CurrentLine; int col = textSelection.CurrentColumn; string file = VisualStudioInstance.ActiveDocument.Name; string project = VisualStudioInstance.ActiveDocument.ProjectItem.ContainingProject.Name; Review newReview = new Review() { ReviewId = _reviewRepo.GetNextReviewId(), Project = project, File = file, Line = line }; ReviewEditor.SetReview(newReview, true); DialogResult result = ReviewEditor.ShowDialog(this); if (result == DialogResult.OK) { ReviewEditor.UpdateReview(newReview); _reviewRepo.Add(newReview); RefreshReviewList(); } } else { MessageBox.Show(SolutionNotOpen); } } catch (Exception ex) { Utils.HandleException(ex); } }
private void Sample1_DialogHost_OnDialogClosing(object sender, DialogClosingEventArgs eventargs) { if (Equals(eventargs.Parameter, true)) { Review review = new Review { ReviewText = tbMovieDesc.Text, Rating = 4 }; ReviewRepository reviewRepository = new ReviewRepository(); reviewRepository.Add(review); Film film = new Film { ReviewId = review.Id, Title = MovieNameTextBox.Text, DateOfProduction = DateTime.Now }; FilmRepository filmRepository = new FilmRepository(); filmRepository.Add(film); } }
public void RepoAdd_AddReview_CheckAdded() { //Arrange var dbmock = new RRRavesDBEntities(); var revrepo = new ReviewRepository(dbmock); Review reviewEx = new Review(); reviewEx.ID_Review = 12; reviewEx.Rating = 4; reviewEx.Restaurant = 1; //Act revrepo.Add(reviewEx); var actual = revrepo.Get(reviewEx.ID_Review); //Assert Assert.Equal(reviewEx, actual); }
/// <summary> /// Saves the given review in the database /// </summary> /// <param name="review"></param> public void addReview(Review review) { reviewRepo.Add(review); }
public void Add(ReviewModel obj) { var itemToAdd = _reviewMapper.MapReviewModelToReviewEntity(obj); _reviewRepository.Add(itemToAdd); }
public async Task <Review> Add(Review entity) { await _repository.Add(entity); return(entity); }
public int AddReview(Review review) { return(_reviewRepository.Add(review)); }