Example #1
0
        public void execute_step_at_instruction_pointer_address()
        {
            var instruction  = new Mock <IInstruction>();
            var instructions = new [] { instruction.Object };
            var computer     = new MockComputerBuilder()
                               .WithDefaultRegisterValue(Computer.InstructionPointer, 0)
                               .WithInstructions(instructions)
                               .Build();

            computer.ExecuteStep();

            instruction.Verify(i => i.Execute(computer), Times.Once);
        }
Example #2
0
        public void advance_instruction_pointer_after_execute_step()
        {
            var instruction  = new Mock <IInstruction>();
            var instructions = new[] { instruction.Object };
            var computer     = new MockComputerBuilder()
                               .WithDefaultRegisterValue(Computer.InstructionPointer, 0)
                               .WithInstructions(instructions)
                               .Build();
            var currentInstructionPointer = computer[Computer.InstructionPointer];

            computer.ExecuteStep();

            Assert.AreEqual(currentInstructionPointer + 1, computer[Computer.InstructionPointer]);
        }
Example #3
0
        public void stop_execution_when_all_executed()
        {
            var instruction  = new Mock <IInstruction>();
            var instructions = new[] { instruction.Object };
            var computer     = new MockComputerBuilder()
                               .WithDefaultRegisterValue(Computer.InstructionPointer, 0)
                               .WithInstructions(instructions)
                               .Build();

            computer.ExecuteAll();

            computer.ExecuteStep();

            instruction.Verify(i => i.Execute(computer), Times.Once);
        }