Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        public async void Process_GetCorrectOutput(char inputLetter, char expectedLetter, bool step, bool expectedStep, ReflectorType type)
        {
            // Arrange
            var utilityFactory = new UtilityFactory();
            var factory        = new ComponentFactory(utilityFactory);
            var reflector      = factory.CreateReflector(type);
            var inputValue     = CommonHelper.LetterToNumber(inputLetter);
            var signal         = await utilityFactory.CreateSignal(inputValue, step, SignalDirection.In);

            // Act
            var resultSignal = await reflector.Process(signal);

            var resultValue  = resultSignal.Value;
            var resultLetter = CommonHelper.NumberToLetter(resultValue);
            var resultStep   = resultSignal.Step;

            // Assert
            Assert.Equal(expectedLetter, resultLetter);
            Assert.Equal(expectedStep, resultStep);
        }