Ejemplo n.º 1
0
        public async Task Register(StudentRegisterContract contract)
        {
            var user   = _mapper.Map(contract);
            var result = await _userManager.CreateAsync(user, contract.Password);

            if (result.Succeeded)
            {
                await _signInManager.SignInAsync(user, false);
            }
        }
Ejemplo n.º 2
0
        public async Task RegisteringStudent_Then_MapperCalled()
        {
            // Arrange
            var contract = new StudentRegisterContract
            {
                Email     = "*****@*****.**",
                Password  = "******",
                FirstName = "name",
                LastName  = "surname",
                GitLink   = "gitLink",
                GroupId   = 1
            };
            var student = new Student
            {
                Email     = "*****@*****.**",
                UserName  = "******",
                FirstName = "name",
                LastName  = "surname",
                GroupId   = 1,
                GitLink   = "gitLink"
            };

            _mapper.Map(contract).Returns(student);
            _userManager.CreateAsync(student, contract.Password).Returns(IdentityResult.Success);

            // Act
            await _usersApi.Register(contract);

            // Assert
            _mapper.Received().Map(contract);
        }