コード例 #1
0
ファイル: PasswordHashTests.cs プロジェクト: No0zZy/Cursed
        public void HashGenrated_HashDifferentFromPassword_ReturnsTrue()
        {
            // arrange
            var password = "******";
            // act
            var hash = passwordHash.GenerateHash(password);

            // assert
            Assert.NotEqual(hash, password);
        }
コード例 #2
0
 private void registerBtn_Click(object sender, EventArgs e)
 {
     try
     {
         var firstName = Sanitize.Capitalize(FirstNameBox.Text);
         var lastName  = Sanitize.Capitalize(LastNameBox.Text);
         Validation.EmailValidation(EmailBox.Text);
         var email       = EmailBox.Text;
         var pwd         = Password(PasswordBox.Text, ConPasswordBox.Text);
         var pwdHashSalt = PasswordHash.GenerateHash(pwd);
         var PasswordH   = pwdHashSalt[0];
         var PasswordS   = pwdHashSalt[1];
         // Create a dictionary of customer to pass to CreateCustomer
         var customerReg = new Customer()
         {
             FirstName = firstName, LastName = lastName, Email = email, PasswordHash = PasswordH, PasswordSalt = PasswordS
         };
         _customer.Add(customerReg);
         MessageBox.Show("Registration Successful", "Success Message");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error in Input");
     }
     EmptyTextBox();
 }
コード例 #3
0
ファイル: BankTestKit.cs プロジェクト: imadonmwinyi/BankApp
        public void InValidRegistrationExceptionTest()
        {
            //Arrange
            var password    = "******";
            var pwdHashSalt = PasswordHash.GenerateHash(password);
            var PasswordH   = pwdHashSalt[0];
            var PasswordS   = pwdHashSalt[1];
            var customer    = new Customer()
            {
                Id           = "8958f787-1123-4294-8b2c-afcd530a97b4",
                Email        = "*****@*****.**",
                FirstName    = "promise",
                LastName     = "Imadonmwinyi",
                PasswordHash = PasswordH,
                PasswordSalt = PasswordS
            };

            //Act

            var ex = Record.Exception(() => _customer.Add(customer));

            //Assert
            Assert.NotNull(ex);
            Assert.IsType <InvalidOperationException>(ex);
        }
コード例 #4
0
ファイル: BankTestKit.cs プロジェクト: imadonmwinyi/BankApp
        public void ValidRegistrationTest()
        {
            //Arrange
            var password    = "******";
            var pwdHashSalt = PasswordHash.GenerateHash(password);
            var PasswordH   = pwdHashSalt[0];
            var PasswordS   = pwdHashSalt[1];
            var customer    = new Customer()
            {
                Id           = "8957f797-1123-4294-8b2c-afcd530a92b4",
                Email        = "*****@*****.**",
                FirstName    = "shalom",
                LastName     = "Imadonmwinyi",
                PasswordHash = PasswordH,
                PasswordSalt = PasswordS
            };
            var expected = true;

            //Act
            var actual = _customer.Add(customer);


            //Assert
            Assert.Equal(expected, actual);
        }
コード例 #5
0
        public void Integration_GenerateHash_IsPasswordMathcingHash()
        {
            string password = "******";


            string hash   = passwordHashProvider.GenerateHash(password);
            bool   actual = passwordHashProvider.IsPasswordMathcingHash(password, hash);


            Assert.True(actual);
        }
コード例 #6
0
        public BankSeedDataFixture()
        {
            var options = new DbContextOptionsBuilder <BankContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            TestBankContext = new BankContext(options);
            // create seed customer data for testing
            var password    = "******";
            var pwdHashSalt = PasswordHash.GenerateHash(password);
            var PasswordH   = pwdHashSalt[0];
            var PasswordS   = pwdHashSalt[1];
            var customer    = new Customer()
            {
                Id           = "8958f787-1123-4294-8b2c-afcd530a97b4",
                Email        = "*****@*****.**",
                FirstName    = "promise",
                LastName     = "Imadonmwinyi",
                PasswordHash = PasswordH,
                PasswordSalt = PasswordS
            };

            TestBankContext.Customers.Add(customer);

            // create seed Savings Account data for testing
            var     cust_id        = "8958f787-1123-4294-8b2a-cfcd530a97b4";
            decimal InitialDeposit = 5000.00m;
            var     acct           = new SavingsAccount()
            {
                AcctNumber  = "7486669202",
                AcctBalance = InitialDeposit,
                AcctType    = "Savings",
                CustomerId  = cust_id,
                DateCreated = DateTime.Now
            };

            TestBankContext.Accounts.Add(acct);
            // create seed Current Account data for testing
            var     C_Id    = "8958f787-1123-4294-8b2a-cfcd530a97b4";
            decimal Deposit = 1000.00m;
            var     C_acct  = new CurrentAccount()
            {
                AcctNumber  = "7437514147",
                AcctBalance = Deposit,
                AcctType    = "Current",
                CustomerId  = C_Id,
                DateCreated = DateTime.Now
            };

            TestBankContext.Accounts.Add(C_acct);
            TestBankContext.SaveChanges();
        }