private static void Main(string[] args) { CeasarCipher start = new CeasarCipher(1); start.Encrypt("home work 2"); Console.WriteLine(start.Encrypt("home work 2")); string nemp = start.Encrypt("home work 2"); start.Decrypt(nemp); Console.WriteLine(start.Decrypt(nemp)); }
public void Dencrypt_WhenEmptyStringIsPassed_ReturnEmptyString() { var cipher = new CeasarCipher(offset: 0); var encrypted = cipher.Decrypt(""); Assert.IsEmpty(encrypted); }
public void EncryptDecrypt_WithRandomSting_ProducesTheSameResult() { var cipher = new CeasarCipher(offset: 5); var word = "Testing with some random string"; var encrypted = cipher.Encrypt(word); Assert.AreEqual(word, cipher.Decrypt(encrypted)); }
public void Decrypt_WithOverflow_ShouldStartFromBegingingOfAlphabet() { var cipher = new CeasarCipher(offset: 1); var word = "!"; var encrypted = cipher.Decrypt(word); Assert.AreEqual("~", encrypted); }
public void EncryptDecrypt_WithRandomSting_plus_enter() { var cipher = new CeasarCipher(offset: 5); var word = "Testing with \r some random string"; var encrypted = cipher.Encrypt(word); Assert.AreEqual(word, cipher.Decrypt(encrypted)); }
public void Dencrypt_WhenPassedNull_ThrowsArgumentNullException() { var cipher = new CeasarCipher(offset: 0); Assert.Throws<ArgumentNullException>(() => { cipher.Decrypt(null); }); }
public void Decrypt_WithZeroOffset_ReturnTheSameWord() { var cipher = new CeasarCipher(offset: 0); var word = "random"; var encrypted = cipher.Decrypt(word); Assert.AreEqual(word, encrypted); }
public void EncryptDecrypt_WithOffsetLargerThanAlphabet_ProducesTheSameResult() { var cipher = new CeasarCipher(offset: 5); var word = "Test string"; var encrypted = cipher.Encrypt(word); Assert.AreEqual(word, cipher.Decrypt(encrypted)); }
public void Decrypt_WithOneOffset_ShiftsSymbolsOnOnePosition() { var cipher = new CeasarCipher(offset: 1); var word = "b"; var encrypted = cipher.Decrypt(word); Assert.AreEqual("a", encrypted); }
public void Decrypt_WithNegativeOffsetOverflow_ShouldStartFromBeginningOfAlphabet() { var cipher = new CeasarCipher(offset: -1); var word = "~"; var decrypted = cipher.Decrypt(word); Assert.AreEqual("!", decrypted); }
public void EncryptDecrypt_WithMinOffset() { var cipher = new CeasarCipher(offset: int.MinValue); var word = "Testing with some random string"; var encrypted = cipher.Encrypt(word); Assert.AreEqual(word, cipher.Decrypt(encrypted)); }
public void Dencrypt_WhenPassedNull_ThrowsArgumentNullException() { var cipher = new CeasarCipher(offset: 0); Assert.Throws <ArgumentNullException>(() => { cipher.Decrypt(null); }); }
public void Dencrypt_WhenPassedWrongSymbol_ThrowsArgumentOutOfRangeException() { var cipher = new CeasarCipher(offset: 0); var nonSymbol = (char)127; var nonSymbolString = new string(new[] { nonSymbol }); Assert.Throws<ArgumentOutOfRangeException>(() => { cipher.Decrypt(nonSymbolString); }); }
public void Dencrypt_WhenPassedWrongSymbol_ThrowsArgumentOutOfRangeException() { var cipher = new CeasarCipher(offset: 0); var nonSymbol = (char)127; var nonSymbolString = new string(new[] { nonSymbol }); Assert.Throws <ArgumentOutOfRangeException>(() => { cipher.Decrypt(nonSymbolString); }); }