public async Task GetAsyncReturnsSearchedElement() { // Arrange var films = new List <Film> { new Film { Rating = 2, AddedByUser = new CinemaUser { UserName = "******", Id = "TestId" }, AddedByUserId = "TestId", FilmData = new FilmData { Title = "TestFilmTitle" }, }, new Film { Rating = 3 } }.AsQueryable(); var mockSet = new Mock <DbSet <Film> >(); mockSet.As <IQueryable <Film> >().Setup(m => m.Provider).Returns(films.Provider); mockSet.As <IQueryable <Film> >().Setup(m => m.Expression).Returns(films.Expression); mockSet.As <IQueryable <Film> >().Setup(m => m.ElementType).Returns(films.ElementType); mockSet.As <IQueryable <Film> >().Setup(m => m.GetEnumerator()).Returns(films.GetEnumerator()); var searchedFilm = films.First(x => x.Rating == 2); var mockContext = new Mock <CinemaDbContext>(); mockContext.Setup(c => c.Films).Returns(mockSet.Object); mockContext.Setup(s => s.Films.FindAsync(It.IsAny <string>())). Returns(new ValueTask <Film>(films.FirstOrDefault(y => y.Id == searchedFilm.Id))); var filmBusiness = new FilmBusiness(mockContext.Object); // Act var resultFilm = await filmBusiness.GetAsync(searchedFilm.Id); // Assert Assert.AreEqual(searchedFilm.Id, resultFilm.Id, "Doesn't return searched element from the film."); Assert.AreEqual(searchedFilm.Rating, resultFilm.Rating, "Doesn't return searched element from the film."); Assert.AreEqual(searchedFilm.AddedByUser, resultFilm.AddedByUser, "Doesn't return searched element from the film."); Assert.AreEqual(searchedFilm.AddedByUserId, resultFilm.AddedByUserId, "Doesn't return searched element from the film."); Assert.AreEqual(searchedFilm.FilmData, resultFilm.FilmData, "Doesn't return searched element from the film."); Assert.AreEqual(searchedFilm.FilmProjection, resultFilm.FilmProjection, "Doesn't return searched element from the film."); Assert.AreEqual(searchedFilm.FilmReviews, resultFilm.FilmReviews, "Doesn't return searched element from the film."); Assert.AreEqual(searchedFilm.OnWatchlistUsers, resultFilm.OnWatchlistUsers, "Doesn't return searched element from the film."); Assert.AreEqual(searchedFilm.Rating, resultFilm.Rating, "Doesn't return searched element from the film."); Assert.AreEqual(searchedFilm.Ratings, resultFilm.Ratings, "Doesn't return searched element from the film."); }