Exemplo n.º 1
0
            public void TestSetPassword()
            {
                string PASSWORD = "******";

                theUser.ChangePassword(null, PASSWORD);

                Assert.AreEqual(theUser.password, theUser.CreateHash(PASSWORD));
            }
Exemplo n.º 2
0
        public void TestSetPassword()
        {
            string PASSWORD = "******";

            theUser.ChangePassword(null, PASSWORD);
            // How do you assert that the password has been set?
            // You can rely on calling the GetPassword method to do this.
            // However, do you really want to provide a
            // method to get the password?

            // OK, let’s write one for now.

            byte[] hashCode = new SHA256Managed().ComputeHash(
                System.Text.Encoding.ASCII.GetBytes(PASSWORD));

            string hashCodeString = BitConverter.ToString(hashCode);

            Assert.AreEqual(hashCodeString, theUser.GetPassword());
        }