コード例 #1
0
        public void IndividualCharScrambleTest()
        {
            int    index;
            String input;
            String expectedOutput;
            String actualOutput;

            for (index = 0; index < charMapping.GetLength(0); index++)
            {
                input          = new String(charMapping[index, 0], 1);
                expectedOutput = "A" + new String(charMapping[index, 1], 1);
                actualOutput   = PasswordScrambler.Scramble(input);
                Assert.IsTrue(actualOutput.Equals(expectedOutput));

                // Just to convince myself that we have iterated over all chars specified in the charMapping
                if (index == 0)
                {
                    Assert.IsTrue(input.Equals("!"));
                }
                else if (index == charMapping.GetLength(0) - 1)
                {
                    Assert.IsTrue(input.Equals("z"));
                }
            }
        }
コード例 #2
0
        public void ScrambleDescrambleTest()
        {
            char          ch;
            StringBuilder input;
            String        scrambledOutput;
            String        descrambledOutput;

            input = new StringBuilder();

            for (ch = (char)1; ch <= (char)0xFF; ch++)
            {
                input.Append(ch);
            }
            scrambledOutput   = PasswordScrambler.Scramble(input.ToString());
            descrambledOutput = PasswordScrambler.Descramble(scrambledOutput);
            Assert.AreEqual(input.ToString(), descrambledOutput);
        }
コード例 #3
0
        public void AllCharsScrambleTest()
        {
            int           index;
            StringBuilder input;
            StringBuilder expectedOutput;
            String        actualOutput;

            input          = new StringBuilder();
            expectedOutput = new StringBuilder();

            expectedOutput.Append("A");

            for (index = 0; index < charMapping.GetLength(0); index++)
            {
                input.Append(charMapping[index, 0]);
                expectedOutput.Append(charMapping[index, 1]);
            }
            actualOutput = PasswordScrambler.Scramble(input.ToString());
            Assert.AreEqual(expectedOutput.ToString(), actualOutput);
        }