Beispiel #1
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));
 }
Beispiel #2
0
        public void Encrypt_WhenEmptyStringIsPassed_ReturnEmptyString()
        {
            var cipher = new CeasarCipher(offset: 0);

            var encrypted = cipher.Encrypt("");

            Assert.IsEmpty(encrypted);
        }
Beispiel #3
0
        public void Encrypt_WithLargeOffset_ShouldStartFromBegingingOfAlphabet()
        {
            var cipher = new CeasarCipher(offset: 109);
            var word   = "~";

            var encrypted = cipher.Encrypt(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));
        }
Beispiel #5
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));
        }
Beispiel #7
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));
        }
        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));
        }
Beispiel #9
0
        public void Encrypt_WithOneOffset_ShiftsSymbolsOnOnePositionRight()
        {
            var cipher = new CeasarCipher(offset: 1);
            var word   = "a";

            var encrypted = cipher.Encrypt(word);

            Assert.AreEqual("b", encrypted);
        }
Beispiel #10
0
        public void Encrypt_WithZeroOffset_ReturnTheSameWord()
        {
            var cipher = new CeasarCipher(offset: 0);
            var word   = "random";

            var encrypted = cipher.Encrypt(word);

            Assert.AreEqual(word, encrypted);
        }
Beispiel #11
0
        public void Encrypt_WhenPassedNull_ThrowsArgumentNullException()
        {
            var cipher = new CeasarCipher(offset: 0);

            Assert.Throws <ArgumentNullException>(() =>
            {
                cipher.Encrypt(null);
            });
        }
Beispiel #12
0
        public void Encrypt_WhenPassedWrongSymbol_ThrowsArgumentOutOfRangeException()
        {
            var cipher          = new CeasarCipher(offset: 0);
            var nonSymbol       = (char)127;
            var nonSymbolString = new string(new[] { nonSymbol });

            Assert.Throws <ArgumentOutOfRangeException>(() =>
            {
                cipher.Encrypt(nonSymbolString);
            });
        }
        public void Encrypt_WhenEmptyStringIsPassed_ReturnEmptyString()
        {
            var cipher = new CeasarCipher(offset: 0);

               var encrypted = cipher.Encrypt("");

               Assert.IsEmpty(encrypted);
        }
        public void Encrypt_WithZeroOffset_ReturnTheSameWord()
        {
            var cipher = new CeasarCipher(offset: 0);
            var word = "random";

            var encrypted = cipher.Encrypt(word);

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

            var encrypted = cipher.Encrypt(word);

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

            var encrypted = cipher.Encrypt(word);

            Assert.AreEqual("b", encrypted);
        }
        public void Encrypt_WhenPassedWrongSymbol_ThrowsArgumentOutOfRangeException()
        {
            var cipher = new CeasarCipher(offset: 0);
            var nonSymbol = (char)127;
            var nonSymbolString = new string(new[] { nonSymbol });

            Assert.Throws<ArgumentOutOfRangeException>(() =>
            {
                cipher.Encrypt(nonSymbolString);
            });
        }
        public void Encrypt_WhenPassedNull_ThrowsArgumentNullException()
        {
            var cipher = new CeasarCipher(offset: 0);

            Assert.Throws<ArgumentNullException>(() =>
            {
                cipher.Encrypt(null);
            });
        }
        public void Encrypt_WithNegativeOffsetOverflow_ShouldStartFromEndOfAlphabet()
        {
            var cipher = new CeasarCipher(offset: -1);
            var word = "!";

            var encrypted = cipher.Encrypt(word);

            Assert.AreEqual("~", encrypted);
        }
Beispiel #20
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));
        }