コード例 #1
0
        public void CanChangePassword()
        {
            SignInService service = CreateSignInService();

            string newPassword = "******";

            service.ChangePassword(1, "owner", "pass1234", newPassword);
            User u = service.Login(1, "owner", newPassword);

            Assert.IsNotNull(u);
        }
コード例 #2
0
        public void CanGenerateValidPasswordToken()
        {
            SignInService service = CreateSignInService();
            string        token   = service.SendResetPasswordEmail(1, "owner");

            Assert.IsNotNull(token);

            string newPassword = service.ResetPassword(token);

            Assert.IsNotNull(newPassword);

            User u = service.Login(1, "owner", newPassword);

            Assert.IsNotNull(u);
        }
コード例 #3
0
ファイル: Login_Should.cs プロジェクト: gchankov/MVCHoldem
        public void ReturnSignInStatus_WhenCalledWithUsernamePasswordIsPersistentAndShouldLockout()
        {
            // Arrange
            var applicationSignInManagerMock = new Mock <IApplicationSignInManager>();
            var applicationUserManagerMock   = new Mock <IApplicationUserManager>();

            applicationSignInManagerMock.Setup(m => m.PasswordSignInAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>()))
            .ReturnsAsync(SignInStatus.Success);
            SignInService authService = new SignInService(applicationSignInManagerMock.Object, applicationUserManagerMock.Object);

            // Act
            var result = authService.Login("username", "password", false, false);

            // Assert
            Assert.AreEqual(SignInStatus.Success, result);
            applicationSignInManagerMock.Verify(m => m.PasswordSignInAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>()), Times.Once);
        }
コード例 #4
0
ファイル: Login_Should.cs プロジェクト: gchankov/MVCHoldem
        public void CallFindByIdAndSignInAsyncOnce_WhenCalledWithUserIdIsPersistentAndShouldLockout()
        {
            // Arrange
            var applicationSignInManagerMock = new Mock <IApplicationSignInManager>();
            var applicationUserManagerMock   = new Mock <IApplicationUserManager>();

            applicationUserManagerMock.Setup(m => m.FindById(It.IsAny <string>()))
            .Returns(new User());
            applicationSignInManagerMock.Setup(m => m.SignInAsync(It.IsAny <User>(), It.IsAny <bool>(), It.IsAny <bool>()))
            .Returns(Task.FromResult(default(object)));
            SignInService authService = new SignInService(applicationSignInManagerMock.Object, applicationUserManagerMock.Object);

            // Act
            authService.Login("user id", false, false);

            // Assert
            applicationUserManagerMock.Verify(m => m.FindById(It.IsAny <string>()), Times.Once);
            applicationSignInManagerMock.Verify(m => m.SignInAsync(It.IsAny <User>(), It.IsAny <bool>(), It.IsAny <bool>()), Times.Once);
        }