Exemple #1
0
        public async Task RegisterShouldCreateUserViaQuery()
        {
            // arrange
            var model = new RegisterModel
            {
                Email       = "*****@*****.**",
                Password    = _random.Next().ToString(),
                FirstName   = "testFirstName",
                Surname     = "testSurname",
                PhoneNumber = "000000000"
            };

            var createdUser = new UserEntity();

            _userQueryProcessorMock.Setup(u => u.Create(It.Is <CreateUserModel>(m =>
                                                                                m.Email == model.Email &&
                                                                                m.Password == model.Password &&
                                                                                m.FirstName == model.FirstName &&
                                                                                m.Surname == model.Surname &&
                                                                                m.PhoneNumber == model.PhoneNumber
                                                                                ))).Returns(Task.FromResult(createdUser));

            // act
            var result = await _accountQueryProcessor.Register(model);

            // assert
            result.Should().Be(createdUser);
        }
        public async Task <UserModel> Register([FromBody] RegisterModel model)
        {
            var result = await _accountQuery.Register(model);

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

            return(resultModel);
        }