Ejemplo n.º 1
0
 public async Task <IList <UserDTO> > Handle(FindAllUsersQuery request, CancellationToken cancellationToken)
 {
     return(await _context.Users.AsNoTracking()
            .Select(a => new UserDTO()
     {
         Id = a.Id,
         Name = a.Login
     }).ToListAsync());
 }
        public void FindAllUsersQuery_Correctly_Builds_Expression()
        {
            var testObject = new FindAllUsersQuery("myApp");

            var exp = testObject.MatchingCriteria;
            Expression body = exp.Body;

            Assert.Equal(ExpressionType.Equal, body.NodeType);
            Assert.Contains("(user.ApplicationName == value(nHibernate.Membership.Provider.Queries.FindAllUsersQuery)._applicationName)", body.ToString());
        }
Ejemplo n.º 3
0
        public void FindAllUsersQuery_Correctly_Builds_Expression()
        {
            var testObject = new FindAllUsersQuery("myApp");

            var        exp  = testObject.MatchingCriteria;
            Expression body = exp.Body;

            Assert.Equal(ExpressionType.Equal, body.NodeType);
            Assert.Contains("(user.ApplicationName == value(nHibernate.Membership.Provider.Queries.FindAllUsersQuery)._applicationName)", body.ToString());
        }
        public void GetAllUsers_Creates_a_FindAllUsersQuery_and_Passes_it_to_Repository()
        {
            var totalRecords      = 0;
            var appName           = "myApp";
            var findAllUsersQuery = new FindAllUsersQuery(appName);

            _queryFactory.Setup(qf => qf.createFindAllUsersQuery(appName)).Returns(findAllUsersQuery);

            var result = testObject.GetAllUsers(0, 0, out totalRecords);

            _repository.Verify(r => r.GetQueryableList(findAllUsersQuery));
        }
        public void GetAllUsers_Creates_a_FindAllUsersQuery_and_Passes_it_to_Repository()
        {
            var totalRecords = 0;
            var appName = "myApp";
            var findAllUsersQuery = new FindAllUsersQuery(appName);

            _queryFactory.Setup(qf => qf.createFindAllUsersQuery(appName)).Returns(findAllUsersQuery);

            var result = testObject.GetAllUsers(0, 0, out totalRecords);

            _repository.Verify(r => r.GetQueryableList(findAllUsersQuery));
        }
Ejemplo n.º 6
0
        public async Task <IEnumerable <UserDto> > Handle(FindAllUsersQuery request, CancellationToken cancellationToken)
        {
            var result = await userRepository.FindAll();

            return(result.Select(x => UserDto.FromDomain(x)).ToList());
        }
Ejemplo n.º 7
0
        public override async Task <Result <IEnumerable <Entity.User> > > Handle(FindAllUsersQuery request, CancellationToken cancellationToken)
        {
            var users = await UnitOfWork.UserRepository.GetAll();

            return(Result <IEnumerable <Entity.User> > .Success(users));
        }