public void Example_program_1() { var cpu = new CPU { Program = new List <Instruction> { new NoOperation(0), new Accumulate(1), new Jump(4), new Accumulate(3), new Jump(-3), new Accumulate(-99), new Accumulate(1), new Jump(-4), new Accumulate(6) } }; AssertAsync.CompletesIn(3, () => { cpu.Run(); }); Assert.Equal(5, cpu.Accumulator); }
public void TestOutput(uint[][] rows, uint[][] columns) { var solve = new Solver(); AssertAsync.CompletesIn(5, () => { var result = solve.Run(rows, columns); output.WriteLine(GraphicsHelper.Map(result)); }); }
public void Puzzle_8A() { var cpu = new CPU(); new ProgramLoader().Load(PuzzleInputs.Puzzle8, cpu); AssertAsync.CompletesIn(1, () => { cpu.Run(); }); Assert.Equal(1451, cpu.Accumulator); }
public void Should_stop_execution_on_halt() { InstructionDecoderMock .Setup(x => x.Decode(It.IsAny <ComputerState>())) .Callback((ComputerState state) => { state.Instruction = new Halt(); }); Computer.State.Memory = new[] { 0 }; AssertAsync .CompletesIn(1, () => Computer.Run()) .Wait(); Assert.True(Computer.State.Halt, "Not halted."); }
public void Run_will_halt_when_before_executing_an_instruction_a_second_time() { var cpu = new CPU { Program = new List <Instruction> { new Accumulate(1), new Jump(-1) } }; AssertAsync.CompletesIn(1, () => { cpu.Run(); }); Assert.Equal(1, cpu.Accumulator); }