Пример #1
0
 public LoginPageViewModel(LoginRegistrationPage currentPage, string returnUrl)
 {
     CurrentPage    = currentPage;
     LoginViewModel = new InternalLoginViewModel()
     {
         ReturnUrl = returnUrl
     };
     RegisterAccountViewModel = new RegisterAccountViewModel
     {
         Address = new AddressModel()
     };
 }
Пример #2
0
        public void InternalLogin_WhenLockedOut_ShoulReturndLockoutView()
        {
            _signinManagerMock.Setup(
                x => x.PasswordSignInAsync(
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<bool>(),
                    It.IsAny<bool>()))
                .Returns(Task.FromResult(SignInStatus.LockedOut));

            var model = new InternalLoginViewModel
            {
                Email = "*****@*****.**",
                Password = "******",
                RememberMe = true,
                ReturnUrl = _testUrl,
            };

            var result = _subject.InternalLogin(model).Result as PartialViewResult;

            result.ViewName.Should().Be("Lockout");
        }
Пример #3
0
        public void InternalLogin_WhenFailure_ShouldReturnModelErrors()
        {
            _signinManagerMock.Setup(
                x => x.PasswordSignInAsync(
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<bool>(),
                    It.IsAny<bool>()))
                .Returns(Task.FromResult(SignInStatus.Failure));

            var model = new InternalLoginViewModel
            {
                Email = "*****@*****.**",
                Password = "******",
                RememberMe = true,
                ReturnUrl = _testUrl,
            };

            var result = _subject.InternalLogin(model);

            _subject.ModelState.Values.First().Errors.First().ErrorMessage.Should().Be("WrongPasswordOrEmail");
        }
Пример #4
0
        public void InternalLogin_WhenSuccessful_ShouldReturnJson()
        {
            _signinManagerMock.Setup(
                x => x.PasswordSignInAsync(
                    It.IsAny<string>(),
                    It.IsAny<string>(),
                    It.IsAny<bool>(),
                    It.IsAny<bool>()))
                .Returns(Task.FromResult(SignInStatus.Success));

            var model = new InternalLoginViewModel
            {
                Email = "*****@*****.**",
                Password = "******",
                RememberMe = true,
                ReturnUrl = _testUrl,
            };

            var result = _subject.InternalLogin(model).Result as JsonResult;

            var expectedResult = new JsonResult
            {
                Data = new { Success = true, ReturnUrl = "/" },     // ReturnUrl should always be without hostname
                JsonRequestBehavior = JsonRequestBehavior.DenyGet
            };

            result.ShouldBeEquivalentTo(expectedResult);
        }