Ejemplo n.º 1
0
        public async Task PostCreateInitialShouldCreateUserAndLogIn()
        {
            var user = new ApplicationUser {
                Id = Guid.NewGuid(), UserName = "******"
            };

            _userService.CreateInitial("a", "b").Returns(user);

            var result = await _controller.CreateInitial(new RegisterViewModel { Username = "******", Password = "******", ConfirmPassword = "******" });

            Assert.IsInstanceOfType(result, typeof(RedirectToActionResult));
            await _signInManager.Received().SignInAsync(user, false, null);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> CreateInitial(RegisterViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var user = await _userService.CreateInitial(vm.Username, vm.Password);

                if (user != null)
                {
                    await _signInManager.SignInAsync(user, false);

                    return(RedirectToAction(nameof(EndpointsController.List), "Endpoints"));
                }
                else
                {
                    return(RedirectToLocal(null));
                }
            }
            else
            {
                return(View(vm));
            }
        }
Ejemplo n.º 3
0
 public async Task CreateInitialShouldNotCreateUserIfOtherUsersExist()
 {
     Assert.IsNull(await _service.CreateInitial("aUser", "aPassword"));
 }