Пример #1
0
        public void ForwardThenInverseShiftProducesSimilarTextWithUnknownLetters()
        {
            var plaintext = "this is a secret message";

            var shifter = new CaesarShifter();

            var shiftedText   = shifter.Shift(plaintext, LetterSet.LowerCaseLatin, 3);
            var unshiftedText = shifter.Shift(shiftedText, LetterSet.LowerCaseLatin, 23);

            Assert.AreEqual(plaintext, unshiftedText);
        }
Пример #2
0
        public void ShiftByNegativeNumberShiftsViaMoulus()
        {
            var plaintext = "this is a secret message";
            var expected  = "wklv lv d vhfuhw phvvdjh";

            var shifter = new CaesarShifter();

            var shiftedText = shifter.Shift(plaintext, LetterSet.LowerCaseLatin, -23);

            Assert.AreEqual(expected, shiftedText);
        }
Пример #3
0
        public void ShiftWithUnkownCharactersLeavesThemInvariant()
        {
            var plaintext = "this is a secret message.";
            var expected  = "wklv lv d vhfuhw phvvdjh.";

            var shifter = new CaesarShifter();

            var shiftedText = shifter.Shift(plaintext, LetterSet.LowerCaseLatin, 3);

            Assert.AreEqual(expected, shiftedText);
        }
Пример #4
0
        public void WellKnownCaesarShiftProducesWellKnownResult()
        {
            var plaintext = "this is a secret message";
            var expected  = "wklv lv d vhfuhw phvvdjh";

            var shifter = new CaesarShifter();

            var shiftedText = shifter.Shift(plaintext, LetterSet.LowerCaseLatin, 3);

            Assert.AreEqual(expected, shiftedText);
        }