Exemplo n.º 1
0
        public async Task ValidadeUserPasswordForHistoryAsync_Invalid_False()
        {
            // Arrange
            var          cxn             = new SqlConnectionWrapperMock();
            var          repository      = new SqlUserRepository(cxn.Object, cxn.Object);
            const int    userId          = 99;
            var          userSalt        = new Guid();
            const string newPassword     = "******";
            var          passwordHystory = new List <SqlUserRepository.HashedPassword>
            {
                new SqlUserRepository.HashedPassword {
                    Password = HashingUtilities.GenerateSaltedHash(newPassword, userSalt), UserSALT = userSalt
                }
            };

            cxn.SetupQueryAsync(
                "GetLastUserPasswords",
                new Dictionary <string, object>
            {
                { "@userId", userId }
            },
                passwordHystory);

            // Act
            var result = await repository.ValidateUserPasswordForHistoryAsync(userId, newPassword);

            // Assert
            cxn.Verify();
            Assert.AreEqual(false, result);
        }
Exemplo n.º 2
0
        public async Task ValidadeUserPasswordForHistoryAsync_Valid_True()
        {
            // Arrange
            var          cxn             = new SqlConnectionWrapperMock();
            var          repository      = new SqlUserRepository(cxn.Object, cxn.Object);
            const int    userId          = 99;
            const string newPassword     = "******";
            var          passwordHystory = new List <SqlUserRepository.HashedPassword>
            {
                new SqlUserRepository.HashedPassword {
                    Password = "******", UserSALT = new Guid()
                }
            };

            cxn.SetupQueryAsync(
                "GetLastUserPasswords",
                new Dictionary <string, object>
            {
                { "@userId", userId }
            },
                passwordHystory);

            // Act
            var result = await repository.ValidateUserPasswordForHistoryAsync(userId, newPassword);

            // Assert
            cxn.Verify();
            Assert.AreEqual(true, result);
        }