Exemplo n.º 1
0
        public UserDto AddUser(UserDto dto)
        {
            User    user           = _modelMapper.FromUserDto(dto);
            User    createdUser    = _userRepository.Add(user);
            UserDto createdUserDto = _modelMapper.ToUserDto(createdUser);

            return(createdUserDto);
        }
Exemplo n.º 2
0
        public void FromUserDto_MapUserFromDtoToModel()
        {
            Guid   id        = new Guid("0f8fad5b-d9cb-469f-a165-70867728950e");
            string login     = "******";
            string firstName = "John";
            string phone     = "123123123";

            UserDto userDto = new UserDto()
            {
                Id        = id,
                Login     = login,
                FirstName = firstName,
                Phone     = phone
            };

            DtoModelMapper mapper = new DtoModelMapper();

            User user = mapper.FromUserDto(userDto);

            Assert.AreEqual(id, user.Id, "Copied 'Id' has invalid value");
            Assert.AreEqual(login, user.Login, "Copied 'login' has invalid value");
            Assert.AreEqual(firstName, user.FirstName, "Copied 'first name' has invalid value");
            Assert.AreEqual(phone, user.Phone, "Copied 'phone' has invalid value");
        }