public void LoadSettings(SavedSettings settings) { Rotor1 = ComponentFactory.CreateRotor(settings.Slot1.RotorType, RotorSlot.One, settings.Slot1.Position); Rotor2 = ComponentFactory.CreateRotor(settings.Slot2.RotorType, RotorSlot.Two, settings.Slot2.Position); Rotor3 = ComponentFactory.CreateRotor(settings.Slot3.RotorType, RotorSlot.Three, settings.Slot3.Position); Reflector = ComponentFactory.CreateReflector(settings.ReflectorType); Plugboard = ComponentFactory.CreatePlugboard(settings.PlugboardConnections); InitializeComponentList(); }
public void Move_GetCorrectPosition(int position, int steps, int expectedPosition) { // Arrange var componentFactory = new ComponentFactory(new UtilityFactory()); var rotor = componentFactory.CreateRotor(RotorType.I, RotorSlot.One, position); // Act rotor.Move(steps); var resultPosition = rotor.PositionShift; //Assert Assert.Equal(resultPosition, expectedPosition); }
public async void Process_GetCorrectOutput(char inputLetter, char expectedLetter, bool step, bool expectedStep, int position, int expectedPosition, RotorType type = RotorType.I, RotorSlot slot = RotorSlot.One) { // Arrange var utilityFactory = new UtilityFactory(); var componentFactory = new ComponentFactory(utilityFactory); var rotor = componentFactory.CreateRotor(type, slot, position); var inputValue = CommonHelper.LetterToNumber(inputLetter); var signal = await utilityFactory.CreateSignal(inputValue, step, SignalDirection.In); // Act var resultSignal = await rotor.Process(signal); var resultValue = resultSignal.Value; var resultLetter = CommonHelper.NumberToLetter(resultValue); var resultStep = resultSignal.Step; // Assert Assert.Equal(expectedLetter, resultLetter); Assert.Equal(expectedStep, resultStep); Assert.Equal(expectedPosition, rotor.PositionShift); }