public async Task UpdateMustUpdateUserAsync()
        {
            // arrange
            var user = new UserEntity {
                Id = Guid.NewGuid()
            };

            _userList.Add(user);

            var model = new UpdateUserModel
            {
                FirstName   = "testFirstName",
                Surname     = "testSurname",
                PhoneNumber = "000000000",
                Email       = "*****@*****.**"
            };

            // act
            var result = await _userQueryProcessor.Update(user.Id, model);

            // assert
            result.Should().Be(user);
            result.FirstName.Should().Be(model.FirstName);
            result.Surname.Should().Be(model.Surname);
            result.PhoneNumber.Should().Be(model.PhoneNumber);

            _unitOfWorkMock.Verify(x => x.CommitAsync());
        }
Ejemplo n.º 2
0
        public async Task <UserModel> PutAsync([FromBody] UpdateUserModel model, Guid id)
        {
            var item = await _userQuery.Update(id, model);

            var resultModel = _mapper.Map <UserModel>(item);

            return(resultModel);
        }
Ejemplo n.º 3
0
        public async Task <UserModel> Put(int id, [FromBody] CreateUpdateUserModel requestModel)
        {
            User item = await _query.Update(id, requestModel);

            UserModel model = _mapper.Map <UserModel>(item);

            return(model);
        }
Ejemplo n.º 4
0
        public async Task UpdateShouldUpdateUserFields()
        {
            var user = new User {
                Id = _random.Next()
            };

            _userList.Add(user);

            var model = new UdpateUserModel
            {
                Username  = _random.Next().ToString(),
                LastName  = _random.Next().ToString(),
                FirstName = _random.Next().ToString(),
            };

            var result = await _query.Update(user.Id, model);

            result.Should().Be(user);
            result.Username.Should().Be(model.Username);
            result.LastName.Should().Be(model.LastName);
            result.FirstName.Should().Be(model.FirstName);

            _uow.Verify(x => x.CommitAsync());
        }
Ejemplo n.º 5
0
 public async Task UpdateExisingUser([FromBody] UserModel model, int id)
 {
     await _userQueryProcessor.Update(id, _autoMapper.Map <UdpateUserModel>(model));
 }