Пример #1
0
 public void TestConnections()
 {
     var plugboard = new Plugboard("ABCKEFGHIJDLNMOPQRSTUZWXYV");
     var rightLeftMappings = AlphabetLetters.Select(c => plugboard.GetMappedLetter(c)).ToArray();
     var leftRightMappings = rightLeftMappings.Select(c => plugboard.GetMappedLetter(c, LetterMapper.MappingDirection.LeftToRight)).ToArray();
     Assert.IsTrue(AlphabetLetters.Zip(leftRightMappings, (c1, c2) => c1 == c2).All(res => res));
 }
Пример #2
0
 public EnigmaMachine()
 {
     _plugboard   = new Plugboard();
     _fastRotor   = new RotorSocket(Rotor.Create("I"));
     _middleRotor = new RotorSocket(Rotor.Create("II"));
     _slowRotor   = new RotorSocket(Rotor.Create("III"));
     _reflector   = new RotorSocket(ReflectorClass.Create("Reflector B"));
 }
Пример #3
0
        public void TestNoConnection()
        {
            var plugboard = new Plugboard();
            var rightLeftMappings = AlphabetLetters.Select(c => plugboard.GetMappedLetter(c)).ToArray();
            var leftRightMappings = AlphabetLetters.Select(c => plugboard.GetMappedLetter(c, LetterMapper.MappingDirection.LeftToRight)).ToArray();
            Assert.IsTrue(rightLeftMappings.Zip(leftRightMappings, (c1, c2) => c1 == c2).All(res => res));

            Assert.IsTrue(rightLeftMappings.Zip(AlphabetLetters, (c1,c2) => c1 == c2).All(res => res));
        }
Пример #4
0
 public void SetupPlugboard(string mappings)
 {
     _plugboard = new Plugboard(mappings);
 }