Пример #1
0
 public void Create_WithoutAbc()
 {
     Assert.Throws<ArgumentNullException>(() =>
     {
         var cipher = new CeasarCipher(null, 0);
     });
 }
Пример #2
0
 public void Create_WithoutAbc()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         var cipher = new CeasarCipher(null, 0);
     });
 }
Пример #3
0
        public void Dencrypt_WhenEmptyStringIsPassed_ReturnEmptyString()
        {
            var cipher = new CeasarCipher(offset: 0);

            var encrypted = cipher.Decrypt("");

            Assert.IsEmpty(encrypted);
        }
Пример #4
0
        public void Dencrypt_WhenEmptyStringIsPassed_ReturnEmptyString()
        {
            var cipher = new CeasarCipher(offset: 0);

            var encrypted = cipher.Decrypt("");

            Assert.IsEmpty(encrypted);
        }
Пример #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));
 }
Пример #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));
        }
Пример #7
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));
        }
Пример #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));
        }
Пример #9
0
        public void Decrypt_WithOverflow_ShouldStartFromBegingingOfAlphabet()
        {
            var cipher = new CeasarCipher(offset: 1);
            var word   = "!";

            var encrypted = cipher.Decrypt(word);

            Assert.AreEqual("~", encrypted);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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));
        }
Пример #15
0
        public void Decrypt_WithOverflow_ShouldStartFromBegingingOfAlphabet()
        {
            var cipher = new CeasarCipher(offset: 1);
            var word = "!";

            var encrypted = cipher.Decrypt(word);

            Assert.AreEqual("~", encrypted);
        }
Пример #16
0
        public void Dencrypt_WhenPassedNull_ThrowsArgumentNullException()
        {
            var cipher = new CeasarCipher(offset: 0);

            Assert.Throws<ArgumentNullException>(() =>
            {
                cipher.Decrypt(null);
            });
        }
Пример #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);
        }
Пример #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);
        }
Пример #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));
        }
Пример #20
0
        public void Dencrypt_WhenPassedNull_ThrowsArgumentNullException()
        {
            var cipher = new CeasarCipher(offset: 0);

            Assert.Throws <ArgumentNullException>(() =>
            {
                cipher.Decrypt(null);
            });
        }
Пример #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);
            });
        }
Пример #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);
            });
        }
Пример #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);
        }
Пример #25
0
        public void Encrypt_WithLargeOffset_ShouldStartFromBegingingOfAlphabet()
        {
            var cipher = new CeasarCipher(offset: 109);
            var word = "~";

            var encrypted = cipher.Encrypt(word);

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