示例#1
0
        public void TurnOver_RotorsMustRotateCorrectlyBasedOnTurnOverNotch(string inputText, string expectedOutputText)
        {
            //Arrange
            IEnigma enigma = new EnigmaI();

            //Act
            string calculatedOutputText = string.Empty;

            for (var i = 0; i < inputText.Length; i++)
            {
                calculatedOutputText += enigma.Write(inputText[i]);
            }

            //Assert
            Assert.Equal(expectedOutputText, calculatedOutputText);
        }
示例#2
0
        public void DecryptSentence_II_I_III_MustBeAValidDecrypt(string inputText, string expectedOutputText)
        {
            //Arrange
            IEnigma enigma = new EnigmaI(new RotorII(), new RotorI(), new RotorIII(), new ReflectorB());

            //Act
            string calculatedOutputText = string.Empty;

            for (var i = 0; i < inputText.Length; i++)
            {
                calculatedOutputText += enigma.Write(inputText[i]);
            }

            //Assert
            Assert.Equal(expectedOutputText, calculatedOutputText);
        }
示例#3
0
        public void AnotherRotorOrder_Rotors_I_III_II_MustConvertCorrectly(string inputText, string expectedOutputText)
        {
            //Arrange
            IEnigma enigma = new EnigmaI(new RotorI(), new RotorIII(), new RotorII(), new ReflectorB());

            //Act
            string calculatedOutputText = string.Empty;

            for (var i = 0; i < inputText.Length; i++)
            {
                calculatedOutputText += enigma.Write(inputText[i]);
            }

            //Assert
            Assert.Equal(expectedOutputText, calculatedOutputText);
        }
示例#4
0
        public void TurnOver_RotorsMustRotateCorrectlyBasedOnTurnOverNotchWithStartedOutterConfiguration(char slowRotorSetting, char middleRotorSetting, char fastRotorSetting, string inputText, string expectedOutputText)
        {
            //Arrange
            IEnigma enigma = new EnigmaI();

            enigma.ConfigureOutterRingSetting(slowRotorSetting, middleRotorSetting, fastRotorSetting);

            //Act
            string calculatedOutputText = string.Empty;

            for (var i = 0; i < inputText.Length; i++)
            {
                calculatedOutputText += enigma.Write(inputText[i]);
            }

            //Assert
            Assert.Equal(expectedOutputText, calculatedOutputText);
        }
示例#5
0
        public void PlugBoardConfigurationMustHaveValidConversion(string plugBoardJumpers, string inputText, string expectedOutputText)
        {
            //Arrange
            IEnigma enigma = new EnigmaI();

            enigma.ConfigurePlugBoard(plugBoardJumpers);

            //Act
            string calculatedOutputText = string.Empty;

            for (var i = 0; i < inputText.Length; i++)
            {
                calculatedOutputText += enigma.Write(inputText[i]);
            }

            //Assert
            Assert.Equal(expectedOutputText, calculatedOutputText);
        }