Esempio n. 1
0
 public void Create_WithoutAbc()
 {
     Assert.Throws<ArgumentNullException>(() =>
     {
         var cipher = new CeasarCipher(null, 0);
     });
 }
Esempio n. 2
0
 public void Create_WithoutAbc()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         var cipher = new CeasarCipher(null, 0);
     });
 }
        public void Dencrypt_WhenEmptyStringIsPassed_ReturnEmptyString()
        {
            var cipher = new CeasarCipher(offset: 0);

            var encrypted = cipher.Decrypt("");

            Assert.IsEmpty(encrypted);
        }
Esempio n. 4
0
        public void Dencrypt_WhenEmptyStringIsPassed_ReturnEmptyString()
        {
            var cipher = new CeasarCipher(offset: 0);

            var encrypted = cipher.Decrypt("");

            Assert.IsEmpty(encrypted);
        }
Esempio n. 5
0
 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));
 }
Esempio n. 6
0
        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 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));
        }
Esempio n. 8
0
        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));
        }
Esempio n. 9
0
        public void Decrypt_WithOverflow_ShouldStartFromBegingingOfAlphabet()
        {
            var cipher = new CeasarCipher(offset: 1);
            var word   = "!";

            var encrypted = cipher.Decrypt(word);

            Assert.AreEqual("~", encrypted);
        }
Esempio n. 10
0
        public void Decrypt_WithOneOffset_ShiftsSymbolsOnOnePosition()
        {
            var cipher = new CeasarCipher(offset: 1);
            var word   = "b";

            var encrypted = cipher.Decrypt(word);

            Assert.AreEqual("a", encrypted);
        }
Esempio n. 11
0
        public void Decrypt_WithZeroOffset_ReturnTheSameWord()
        {
            var cipher = new CeasarCipher(offset: 0);
            var word   = "random";

            var encrypted = cipher.Decrypt(word);

            Assert.AreEqual(word, encrypted);
        }
Esempio n. 12
0
        public void Encrypt_WithLargeOffset_ShouldStartFromBegingingOfAlphabet()
        {
            var cipher = new CeasarCipher(offset: 109);
            var word   = "~";

            var encrypted = cipher.Encrypt(word);

            Assert.AreEqual("!", encrypted);
        }
        public void Decrypt_WithNegativeOffsetOverflow_ShouldStartFromBeginningOfAlphabet()
        {
            var cipher = new CeasarCipher(offset: -1);
            var word = "~";

            var decrypted = cipher.Decrypt(word);

            Assert.AreEqual("!", decrypted);
        }
Esempio n. 14
0
        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));
        }
Esempio n. 15
0
        public void Decrypt_WithOverflow_ShouldStartFromBegingingOfAlphabet()
        {
            var cipher = new CeasarCipher(offset: 1);
            var word = "!";

            var encrypted = cipher.Decrypt(word);

            Assert.AreEqual("~", encrypted);
        }
Esempio n. 16
0
        public void Dencrypt_WhenPassedNull_ThrowsArgumentNullException()
        {
            var cipher = new CeasarCipher(offset: 0);

            Assert.Throws<ArgumentNullException>(() =>
            {
                cipher.Decrypt(null);
            });
        }
Esempio n. 17
0
        public void Decrypt_WithZeroOffset_ReturnTheSameWord()
        {
            var cipher = new CeasarCipher(offset: 0);
            var word = "random";

            var encrypted = cipher.Decrypt(word);

            Assert.AreEqual(word, encrypted);
        }
Esempio n. 18
0
        public void Decrypt_WithOneOffset_ShiftsSymbolsOnOnePosition()
        {
            var cipher = new CeasarCipher(offset: 1);
            var word = "b";

            var encrypted = cipher.Decrypt(word);

            Assert.AreEqual("a", encrypted);
        }
Esempio n. 19
0
        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));
        }
Esempio n. 20
0
        public void Dencrypt_WhenPassedNull_ThrowsArgumentNullException()
        {
            var cipher = new CeasarCipher(offset: 0);

            Assert.Throws <ArgumentNullException>(() =>
            {
                cipher.Decrypt(null);
            });
        }
Esempio n. 21
0
        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);
            });
        }
Esempio n. 22
0
        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);
            });
        }
Esempio n. 23
0
        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 Encrypt_WithNegativeOffsetOverflow_ShouldStartFromEndOfAlphabet()
        {
            var cipher = new CeasarCipher(offset: -1);
            var word = "!";

            var encrypted = cipher.Encrypt(word);

            Assert.AreEqual("~", encrypted);
        }
        public void Encrypt_WithLargeOffset_ShouldStartFromBegingingOfAlphabet()
        {
            var cipher = new CeasarCipher(offset: 109);
            var word = "~";

            var encrypted = cipher.Encrypt(word);

            Assert.AreEqual("!", encrypted);
        }