public EnigmaMachine() { _plugboard = new Plugboard(); _fastRotor = new RotorSocket(Rotor.Create(RotorVariation.FirstTypeRotor)); _middleRotor = new RotorSocket(Rotor.Create(RotorVariation.SecondTypeRotor)); _slowRotor = new RotorSocket(Rotor.Create(RotorVariation.ThirdTypeRotor)); _reflector = new RotorSocket(Reflector.Create(ReflectorVariation.FirstTypeReflector)); }
public void TestNotch() { var socket = new RotorSocket(Rotor.Create("I")); while (!socket.IsSocketInNotchPosition) { socket.Advance(); } Assert.AreEqual('Q', socket.CurrentRingLetter); }
public void TestLetterMappingsWithRotorOffsetSettings() { var socket = new RotorSocket(Rotor.Create("I", 'B')); Assert.AreEqual('K', socket.GetMappedLetter('A')); Assert.AreEqual('A', socket.GetMappedLetter('K', LetterMapper.MappingDirection.LeftToRight)); socket.Advance(); Assert.AreEqual('E', socket.GetMappedLetter('A')); Assert.AreEqual('A', socket.GetMappedLetter('E', LetterMapper.MappingDirection.LeftToRight)); }
public void TestLetterMappings() { var socket = new RotorSocket(Rotor.Create("I")); Assert.AreEqual('E', socket.GetMappedLetter('A')); Assert.AreEqual('A', socket.GetMappedLetter('E', LetterMapper.MappingDirection.LeftToRight)); //If for example rotor I is in the B-position, an A enters at the letter B //which is wired to the K. Because of the offset this K enters the next rotor in the J position. socket.Advance(); Assert.AreEqual('J', socket.GetMappedLetter('A')); Assert.AreEqual('A', socket.GetMappedLetter('J', LetterMapper.MappingDirection.LeftToRight)); }
public void TestRotorOffsets() { var socket = new RotorSocket(Rotor.Create("I")); Assert.AreEqual('A', socket.CurrentRingLetter); socket.Advance(); Assert.AreEqual('B', socket.CurrentRingLetter); socket.Reset(); Assert.AreEqual('A', socket.CurrentRingLetter); for (int i = 0; i < 26; i++) { socket.Advance(); } Assert.AreEqual('A', socket.CurrentRingLetter); }
private void MoveRotors() { bool slowRotorIncremented = false; if (_middleRotor.IsSocketInNotchPosition) { slowRotorIncremented = true; _slowRotor = _slowRotor.Advance(); } if (_fastRotor.IsSocketInNotchPosition || slowRotorIncremented) { _middleRotor = _middleRotor.Advance(); } _fastRotor = _fastRotor.Advance(); }
public void ResetRotors() { _fastRotor = _fastRotor.Reset(); _middleRotor = _middleRotor.Reset(); _slowRotor = _slowRotor.Reset(); }
public void SetStartupRotorRingLetters(char[] letters) { _slowRotor = _slowRotor.SetStartingRingLetter(letters[0]); _middleRotor = _middleRotor.SetStartingRingLetter(letters[1]); _fastRotor = _fastRotor.SetStartingRingLetter(letters[2]); }
public void SetupReflector(ReflectorVariation type) { _reflector = _reflector.SetupRotor(Reflector.Create(type)); }
public void SetupRotors(RotorsConfigurationSetup configuration) { _slowRotor = _slowRotor.SetupRotor(configuration.SlowRotor); _middleRotor = _middleRotor.SetupRotor(configuration.MiddleRotor); _fastRotor = _fastRotor.SetupRotor(configuration.FastRotor); }