public void SetEncryptionKeyReturnsCorrectTextForOneRotor() { const string plaintext = "HELLO"; Rotor[] rotors = new Rotor[1]; rotors[0] = new Rotor(AlphabetUtils.AlphabetString, "rotor"); Enigma enigma = new Enigma(rotors); enigma.SetEncryptionKey("A"); Assert.AreEqual(AlphabetUtils.AlphabetString, enigma.SubmitString(AlphabetUtils.AlphabetString)); Assert.AreEqual(AlphabetUtils.ReverseAlphabetString, enigma.SubmitString(AlphabetUtils.ReverseAlphabetString)); Assert.AreEqual(plaintext, enigma.SubmitString(plaintext)); }
public void SetEncryptionKeyReturnsCorrectTextForOneRotorAndOneDeflectorAndOneLetterInput() { const string plaintext = "A"; Rotor[] rotors = new Rotor[2]; rotors[0] = new Rotor(AlphabetUtils.AlphabetString, "rotor"); rotors[1] = new Rotor(AlphabetUtils.ReverseAlphabetString, "reflector"); Enigma enigma = new Enigma(rotors); enigma.SetEncryptionKey("BB"); string ciphertext = enigma.SubmitString(plaintext); Assert.AreEqual(plaintext, enigma.SubmitString(ciphertext), "Encryption symmetry is not ensured."); }
public void SymmetryIsEnsuredWithOneFixedRotorAndReflector() { const string plaintext = "HELLO"; Rotor[] rotors = new Rotor[2]; rotors[0] = new Rotor(AlphabetUtils.AlphabetString, "rotor"); rotors[1] = new Rotor(AlphabetUtils.ReverseAlphabetString, "reflector"); Enigma enigma = new Enigma(rotors); enigma.SetEncryptionKey("BB"); string ciphertext = enigma.SubmitString(plaintext); Assert.AreEqual(plaintext, enigma.SubmitString(ciphertext), "Encryption symmetry is not ensured."); }