示例#1
0
        private static NestedEnigmaMachine BuildEnigma(char[] ringSettings = null)
        {
            if (ringSettings == null)
            {
                ringSettings = new char[] { 'A', 'A', 'A' };
            }
            NestedRotor rotorI = NestedEnigmaMachineTestSupport.CreateRotorI();

            rotorI.SetRingSetting(ringSettings[0]);
            NestedRotor rotorII = NestedEnigmaMachineTestSupport.CreateRotorII();

            rotorII.SetRingSetting(ringSettings[1]);
            NestedRotor rotorIII = NestedEnigmaMachineTestSupport.CreateRotorIII();

            rotorIII.SetRingSetting(ringSettings[2]);
            EnigmaReflector     reflectorB = NestedEnigmaMachineTestSupport.CreateBReflector();
            NestedEnigmaMachine enigma     = new NestedEnigmaMachine();

            EnigmaRotor[] rotors = new EnigmaRotor[4];
            rotors[0] = reflectorB;
            rotors[1] = rotorI;
            rotors[2] = rotorII;
            rotors[3] = rotorIII;

            enigma.SetRotors(rotors);
            return(enigma);
        }
示例#2
0
        public void NestedRotor_MappslettersWithRingSetting()
        {
            char        expected = 'K';
            NestedRotor Rotor_I  = CreateRotorI();

            Rotor_I.SetRingSetting('B');
            char actual = Rotor_I.Convert('A');

            Assert.AreEqual(expected, actual);
        }