public void FindReturnsCorrectCarsList(IQueryable <Review> data)
        {
            //Arrange
            var mockSet = new Mock <DbSet <Review> >();

            mockSet.As <IQueryable <Review> >().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As <IQueryable <Review> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <Review> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <Review> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator);

            var mock = new Mock <RentContext>();

            mock.Setup(a => a.Reviews).Returns(mockSet.Object);

            //Act
            var repository = new ReviewRepository(mock.Object);
            var result     = repository.Find(review => review.Text.Contains("simple"));

            //Assert
            Assert.That(result, Has.Count.EqualTo(2).And.TypeOf(typeof(List <Review>)));
        }
 /// <summary>
 /// Removes the review with the given ID from the database
 /// </summary>
 /// <param name="reviewId"></param>
 public void removeReview(int reviewId)
 {
     reviewRepo.Delete(reviewRepo.Find(reviewId));
 }
Esempio n. 3
0
 public Review Find(long?id)
 {
     return(_reviewRepository.Find(id));
 }