public void ReturnFalseWhenAutopartIsNotFavoriteForUser() { var list = new List <Favorite>(); var mockRepository = new Mock <IDeletableEntityRepository <Favorite> >(); mockRepository .Setup(x => x.AllAsNoTracking()) .Returns(list.AsQueryable()); var autopartId = 123; var userId = "User_01"; list.Add(new Favorite { AutopartId = 321, UserId = "User_02" }); var service = new FavoritesService(mockRepository.Object); var result = service.CheckIfAutopartIsFavoriteForUser(userId, autopartId); Assert.False(result); }