public void Get_Move_Instruction_Test() { IInstructionFactory instructionFactory = new InstructionFactory(); var moveInstruction = instructionFactory.GetInstruction(Command.Move); Assert.IsInstanceOfType(moveInstruction, typeof(MoveInstruction)); }
public void Get_Turn_Right_Instruction_Test() { IInstructionFactory instructionFactory = new InstructionFactory(); var moveInstruction = instructionFactory.GetInstruction(Command.Right); Assert.IsInstanceOfType(moveInstruction, typeof(TurnRightInstruction)); }
public void GivenInstructionToggle0x0Through999x999_WhenGetAmountOfTristateLightingLights_ThenReturnTwoMillion() { var lightingAll = InstructionFactory.GetInstruction("toggle 0,0 through 999,999"); var result = _sut.GetAmountOfTristateLightingLights(new List <Instruction> { lightingAll }); Assert.Equal(result, 2000000); }
public void GivenInstructionTurnOn0x0Through0x0_WhenGetAmountOfTristateLightingLights_ThenReturnOne() { var lightingOne = InstructionFactory.GetInstruction("turn on 0,0 through 0,0"); var result = _sut.GetAmountOfTristateLightingLights(new List <Instruction> { lightingOne }); Assert.Equal(result, 1); }
public void GivenInstructionToggle0x0Through999x0_WhenGetAmountOfSimpleLightingLights_ThenReturnOneThousand() { var lightingFirstRow = InstructionFactory.GetInstruction("toggle 0,0 through 999,0"); var result = _sut.GetAmountOfSimpleLightingLights(new List <Instruction> { lightingFirstRow }); Assert.Equal(result, 1000); }
public void GivenInstructionTurnOn0x0Through999x999_WhenGetAmountOfSimpleLightingLights_ThenReturnOneMillion() { var lightingAll = InstructionFactory.GetInstruction("turn on 0,0 through 999,999"); var result = _sut.GetAmountOfSimpleLightingLights(new List <Instruction> { lightingAll }); Assert.Equal(result, 1000000); }
public void GivenInstructionTurnOff499x499Through500x500_WhenGetAmountOfSimpleLightingLights_ThenReturnFour() { var lightingAll = InstructionFactory.GetInstruction("turn on 0,0 through 999,999"); var lightingSome = InstructionFactory.GetInstruction("turn off 499,499 through 500,500"); var result = _sut.GetAmountOfSimpleLightingLights(new List <Instruction> { lightingAll, lightingSome }); Assert.Equal(result, 1000000 - 4); }
public static Computer Load(IEnumerable <string> instructions) { var factory = new InstructionFactory(); var lines = instructions.ToArray(); var instructionSet = new List <IInstruction>(lines.Length); foreach (var line in lines) { instructionSet.Add(factory.GetInstruction(line)); } return(new Computer(new Memory(), instructionSet)); }
public void Step() { IInstruction instruction = InstructionFactory.GetInstruction(_vmstate, _program, _inputProvider, _outputProvider); if (instruction is StopInstruction) { IsDone = true; } else { _instructionPointer = instruction.Execute(); } }
public void Get_Exception_Instruction_Test() { IInstructionFactory instructionFactory = new InstructionFactory(); var moveInstruction = instructionFactory.GetInstruction('I'); }