public async Task <IEnumerable <T> > FindByPredicateAsync(Expression <Func <T, bool> > match)
        {
            var entities = await EntityCollection
                           .AsQueryable()
                           .Where(match)
                           .ToListAsync(); // Hackerman

            return(entities);
        }
Esempio n. 2
0
        public async Task FollowUserSuccess(string currentUserName, string userNameToFollow)
        {
            // Arrange
            var mockUserRepository = new Mock <IUserProfileRepository>();

            mockUserRepository.Setup(x => x.GetAsync(It.IsAny <Expression <Func <UserProfileEntity, bool> > >()))
            .Returns((Expression <Func <UserProfileEntity, bool> > x) =>
                     Task.FromResult(EntityCollection.AsQueryable <UserProfileEntity>().Where(x).AsEnumerable()));

            mockUserRepository.Setup(x => x.UpdateAsync(It.IsAny <UserProfileEntity>()))
            .Callback((UserProfileEntity user) =>
            {
                var userToUpdate = EntityCollection.Single(x => string.Equals(x.UserName, user.UserName));
                userToUpdate     = user.UserName switch
                {
                    var usrCurrent when usrCurrent == currentUserName => userToUpdate with {
                        Follows = user.Follows
                    },
                    var usrToFollow when usrToFollow == userNameToFollow => userToUpdate with {
                        Followers = user.Followers
                    },
 public IQueryable <T> AsQueryable() => EntityCollection.AsQueryable();