コード例 #1
0
        public void ROT_13_TEST()
        {
            ShiftCipher myCipher = new ShiftCipher(ShiftCipher.MODE.ROT13);

            Assert.AreEqual(ShiftCipher.MODE.ROT13, myCipher.GetMode(), "default shift mode not set correctly");
            Assert.AreEqual(0, myCipher.GetKey(), "Incorrect defualt shift amount found");
            myCipher.GenKey();
            Assert.AreEqual(ROT_13_SHIFT, myCipher.GetKey(), "Incorrect shift amount found");
            string encStr = myCipher.Encrypt(TEST_STR);

            TestStrEnc(myCipher, encStr);
            TestStrDec(encStr, myCipher.Decrypt(encStr));
        }
コード例 #2
0
        public void SetKeyTest()
        {
            ShiftCipher shiftCipher = new ShiftCipher();

            TestCtor(shiftCipher);
            shiftCipher.SetKey(TEST_SHIFT);
            Assert.AreEqual(TEST_SHIFT, shiftCipher.GetKey(), "Incorrect key returned");
        }
コード例 #3
0
        public void GenKeyTest()
        {
            ShiftCipher shiftCipher = new ShiftCipher();

            TestCtor(shiftCipher);
            shiftCipher.GenKey();
            Assert.AreNotEqual(0, shiftCipher.GetKey(), "key was not intialized");
        }
コード例 #4
0
 static void TestStrEnc(ShiftCipher cipher, string encStr)
 {
     Assert.AreNotEqual(0, cipher.GetKey(), "Key was not Generated");
     Assert.AreNotEqual(TEST_STR, encStr, "String did not encrypt");
 }
コード例 #5
0
 static void TestCtor(ShiftCipher cipher)
 {
     Assert.AreEqual(ShiftCipher.MODE.SHIFT, cipher.GetMode(), "default shift mode not set correctly");
     Assert.AreEqual(0, cipher.GetKey(), "Incorrect defualt shift amount found");
 }