Beispiel #1
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);
        }
Beispiel #2
0
        public async void Process_GetCorrectOutput(Dictionary <char, char> connections, char inputLetter, char expectedLetter, bool step, bool expectedStep)
        {
            // Arrange
            var utilityFactory = new UtilityFactory();
            var factory        = new ComponentFactory(utilityFactory);
            var plugboard      = factory.CreatePlugboard(connections);
            var inputValue     = CommonHelper.LetterToNumber(inputLetter);
            var signal         = await utilityFactory.CreateSignal(inputValue, step, SignalDirection.In);

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

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

            // Assert
            Assert.Equal(expectedLetter, resultLetter);
            Assert.Equal(expectedStep, resultStep);
        }
Beispiel #3
0
        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);
        }