Beispiel #1
0
        private static ISteckeredEnigma BuildEnigma(char[] ringSettings = null)
        {
            if (ringSettings == null)
            {
                ringSettings = new char[] { 'A', 'A', 'A' };
            }

            EnigmaFactory    factory = new EnigmaFactory();
            ISteckeredEnigma enigma  = factory.GetEnigmaI(Reflector.B, new Rotor[] { Rotor.I, Rotor.II, Rotor.III });

            enigma.SetRingSetting("AAA");
            //EnigmaRotor rotorI = EnigmaIMachineTestSupport.CreateRotorI();
            //rotorI.SetRingSetting(ringSettings[0]);
            //EnigmaRotor rotorII = EnigmaIMachineTestSupport.CreateRotorII();
            //rotorII.SetRingSetting(ringSettings[1]);
            //EnigmaRotor rotorIII = EnigmaIMachineTestSupport.CreateRotorIII();
            //rotorIII.SetRingSetting(ringSettings[2]);
            //EnigmaReflector reflectorB = EnigmaIMachineTestSupport.CreateBReflector();
            //EnigmaI enigma = new EnigmaI();

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

            //enigma.SetRotors(rotors);
            return(enigma);
        }
Beispiel #2
0
        private static ISteckeredEnigma BuildEnigma()
        {
            EnigmaFactory    factory = new EnigmaFactory();
            ISteckeredEnigma enigma  = factory.GetEnigmaM4(Reflector.BThin, new Rotor[] { Rotor.I, Rotor.I, Rotor.III, Rotor.Beta });

            return(enigma);
        }
Beispiel #3
0
        public void EnigmaI_RotorOrderIsCorrect_ConfirmByDoublestepping()
        {
            string        startingOffset = "AEW";
            string        expected       = "BFX";
            EnigmaFactory factory        = new EnigmaFactory();
            var           enigmaI        = factory.GetEnigmaI(Reflector.A, new Rotor[] { Rotor.I, Rotor.II, Rotor.III });

            enigmaI.SetRotorOffset(startingOffset);
            enigmaI.Crypt("A");
            string actual = enigmaI.GetRotorSettings();

            Assert.AreEqual(expected, actual);
        }
Beispiel #4
0
 public void CanConstructEnigmaM4()
 {
     EnigmaFactory  factory = new EnigmaFactory();
     IEnigmaMachine enigma  = factory.GetEnigmaM4(Reflector.BThin, new Rotor[] { Rotor.I, Rotor.I, Rotor.III, Rotor.Beta });
 }
Beispiel #5
0
 public void EnigmaI_RejectsDuplicateRotors()
 {
     EnigmaFactory factory = new EnigmaFactory();
     var           enigmaI = factory.GetEnigmaI(Reflector.A, new Rotor[] { Rotor.I, Rotor.I, Rotor.III });
 }
Beispiel #6
0
 public void EnigmaI_RejectsInvalidRotors()
 {
     EnigmaFactory factory = new EnigmaFactory();
     var           enigmaI = factory.GetEnigmaI(Reflector.A, new Rotor[] { Rotor.VIII, Rotor.II, Rotor.III });
 }
Beispiel #7
0
        public void CanConstructEnigmaI()
        {
            EnigmaFactory factory = new EnigmaFactory();

            factory.GetEnigmaI(Reflector.A, new Rotor[] { Rotor.I, Rotor.II, Rotor.III });
        }
Beispiel #8
0
 public void CanConstructEnigmaFactory()
 {
     EnigmaFactory factory = new EnigmaFactory();
 }