public void GivenInput123ToX_WhenGet_ThenReturnCorrectSignalInstruction() { var instruction = _sut.Get("123 -> x"); Assert.Equal(instruction, new Instruction(new List <string>() { "123" }, new SignalGate(), "x")); }
public int Execute() { var instructionFactory = new InstructionFactory(_registers); var currentInstructionIndex = 0; _registers['c'] = 1; while (currentInstructionIndex < _instructions.Length && currentInstructionIndex >= 0) { var instructionType = instructionFactory.Get(_instructions[currentInstructionIndex]); currentInstructionIndex = instructionType.Execute(currentInstructionIndex); } return(_registers['a']); }