Beispiel #1
0
        public void Should_encode_message_with_given_keyword()
        {
            // Arrange
            const string expected = "egsgqwtahuiljgs";
            var          sut      = new AlphabetCipher("scones");

            // Act
            var actual = sut.Encode("meetmebythetree");

            // Assert
            Assert.AreEqual(expected, actual);
        }
Beispiel #2
0
        public void Encode_does_correct_substitution(
            string alphabet,
            char keyChar,
            char inputChar,
            char expected
            )
        {
            var sut    = new AlphabetCipher(alphabet);
            var result = sut.Encode(inputChar, keyChar);

            Assert.Equal(expected, result);
        }
Beispiel #3
0
        static int Main(string[] args)
        {
            if (args.Count() < 2)
            {
                Console.WriteLine("Usage: encode key input");
                return(1);
            }

            var key    = args[0].ToLower();
            var input  = args[1].ToLower();
            var cipher = new AlphabetCipher();

            Console.WriteLine(cipher.Encode(input, key));

            return(0);
        }