public void Get_OnCall_ReturnsAllReviews() { var reviews = new List <Review> { new Review { ReviewId = Guid.NewGuid(), ReviewPublicId = Guid.NewGuid(), Restaurant = _testContext.Restaurants.First() }, new Review { ReviewId = Guid.NewGuid(), ReviewPublicId = Guid.NewGuid(), Restaurant = _testContext.Restaurants.First() }, new Review { ReviewId = Guid.NewGuid(), ReviewPublicId = Guid.NewGuid(), Restaurant = _testContext.Restaurants.First() }, }; _testContext.Reviews.RemoveRange(_testContext.Reviews); _testContext.Reviews.AddRange(reviews); _testContext.SaveChanges(); var result = _reviewRepository.Get(); const int expected = 3; Assert.AreEqual(expected, result.Count()); }
/// <summary> /// Handles the CellDoubleClick event of the gvReviews control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.DataGridViewCellEventArgs"/> instance containing the event data.</param> private void gvReviews_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { var row = ReviewGrid.Rows[e.RowIndex]; var reviewId = int.Parse(row.Cells[Review.ColumnReviewId].Value.ToString()); bool itemFound = false; foreach (Project project in VisualStudioInstance.Solution.Projects) { VSIDEHelper.ScanForProjectItems(project, _reviewRepo.Get(reviewId), HandleProjectItem, out itemFound); if (itemFound) { return; } } if (!itemFound) { MessageBox.Show("Project item not found", Utils.AssemblyTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { Utils.HandleException(ex); } }
public void ReviewRepository_EditExistingReview_RatingChanged() { var editedReview = new Review() { BarName = "Katrines Kælder", Username = "******", BarPressure = 0, }; _uut.Edit(editedReview); _context.SaveChanges(); Assert.AreEqual(0, _uut.Get("Katrines Kælder", "Bodega Bent").BarPressure); }
private void btnDelete_Click(object sender, RoutedEventArgs e) { try { Review review = (Review)ReviewGrid.SelectedItem; if (review != null) { //TODO: Add a confirmation here. //DialogResult result = MessageBox.Show("Are you sure to delete this item?", Utils.AssemblyTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question); //if (DialogResult.Yes == result) //{ Review reviewToDelete = _reviewRepo.Get(review.ReviewId); _reviewRepo.Delete(reviewToDelete); RefreshReviewList(); //} } else { MessageBox.Show("No current row to Delete", Utils.AssemblyTitle); } } catch (Exception ex) { Utils.HandleException(ex); } }
public async Task GetTest() { //Arrange using (var context = new AppDbContext(options)) { var review = new GoodReview { Id = 1, CustomerId = 1 }; var customer = new Customer { Id = 1, FirstName = "Test" }; var repo = new ReviewRepository(context); //Act context.Customers.Add(customer); context.Reviews.Add(review); context.SaveChanges(); var actualResult = await repo.Get(review.Id); var expectedResult = review; //Assert Assert.AreEqual(expectedResult, actualResult); } }
public ActionResult AdminIndex(string productTitle, string currentFilter, bool?isApproved, bool?isNotRead, int?page) { var pageNumber = page ?? 1; if (productTitle != null) { page = 1; } else { productTitle = currentFilter; } var objectsPerPage = 20; var searchResult = _reviewRepository.Get(new SearchParamsReview(productTitle, isApproved, isNotRead, (pageNumber - 1) * objectsPerPage, objectsPerPage)); ViewBag.CurrentFilter = productTitle; ViewBag.IsApproved = isApproved; ViewBag.IsRead = isNotRead; var viewModel = SearchResultViewModel <Review> .CreateFromSearchResult(searchResult, i => i, 10); return(View(viewModel)); }
public void GetReturnsReviewOnCorrectId() { //Arrange var mockSet = new Mock <DbSet <Review> >(); mockSet.Setup(a => a.Find(It.IsAny <int>())).Returns(new Review()); var mock = new Mock <RentContext>(); mock.Setup(a => a.Reviews).Returns(mockSet.Object); //Act var repository = new ReviewRepository(mock.Object); var result = repository.Get(1); //Assert Assert.That(result, Is.TypeOf(typeof(Review))); }
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); }
public IActionResult ViewReviews() { var reviews = reviewRepository.Get(a => a.Flagged == false); return(View(reviews)); }
public async Task <ActionResult <IEnumerable <ReviewDTO> > > GetReviews(int?productID) { return(Ok(await _reviewRepository.Get(review => !productID.HasValue || review.ProductID == productID))); }
// GET: api/Reviews public IQueryable <Review> GetReviews() { return(_context.Get()); }
public Review GetReview(int id) { return(_reviewRepository.Get(id)); }