Beispiel #1
0
 public RotorSettingsController(IEventAggregator settingsAggregator, IComponentFactory componentFactory, IEnigmaSettings enigmaSettings, RotorSlot slot)
 {
     _settingsAggregator = settingsAggregator;
     _componentFactory   = componentFactory;
     _enigmaSettings     = enigmaSettings;
     _slot  = slot;
     _rotor = _enigmaSettings.GetRotor(slot);
 }
Beispiel #2
0
        public Rotor(RotorSlot slot, int position, char[] connections, RotorType type, IEventAggregator eventAggregator, IUtilityFactory utilityFactory)
        {
            _utilityFactory = utilityFactory;

            Connections     = connections;
            Slot            = slot;
            PositionShift   = position;
            Type            = type;
            RotorAggregator = eventAggregator;
        }
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);
        }
Beispiel #4
0
 public IRotor GetRotor(RotorSlot slot)
 {
     return(null);
 }
Beispiel #5
0
        public RotorViewModel(IEventAggregator settingsAggregator, IComponentFactory componentFactory, RotorSlot slot, IEnigmaSettings enigmaSettings, HelpersViewModelFactory helpersViewModelFactory)
        {
            RotorTypes           = Enum.GetValues(typeof(RotorType)).Cast <RotorType>();
            _componentController = new RotorSettingsController(settingsAggregator, componentFactory, enigmaSettings, slot);

            var componentAggregator = _componentController.GetAggregator();
            var connections         = _componentController.GetConnections();
            var positionShift       = _componentController.GetPositionShift();

            RotorType = _componentController.GetRotorType();

            _viewController   = new RotorViewController(componentAggregator, helpersViewModelFactory, connections, positionShift);
            AlphabetViewModel = _viewController.GetAlphabetView();
        }
        public IRotor CreateRotor(RotorType type, RotorSlot slot, int position)
        {
            var aggregator = CreateEventAggregator();

            return(new Rotor(slot, position, _rotorConnections[type], type, aggregator, UtilityFactory));
        }
Beispiel #7
0
 public IRotor GetRotor(RotorSlot slot) => slot switch
 {
Beispiel #8
0
 public RotorViewModel Create(RotorSlot Slot)
 {
     return(new RotorViewModel(_enigmaAggregator, _componentFactory, Slot, _enigmaSettings, _helpersViewModelFactory));
 }