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)); }
public void SetKeyTest() { ShiftCipher shiftCipher = new ShiftCipher(); TestCtor(shiftCipher); shiftCipher.SetKey(TEST_SHIFT); Assert.AreEqual(TEST_SHIFT, shiftCipher.GetKey(), "Incorrect key returned"); }
public void GenKeyTest() { ShiftCipher shiftCipher = new ShiftCipher(); TestCtor(shiftCipher); shiftCipher.GenKey(); Assert.AreNotEqual(0, shiftCipher.GetKey(), "key was not intialized"); }
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"); }
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"); }