Beispiel #1
0
        public void ExecuteStep_NothingToExecute_Throws()
        {
            var sut     = new ExecutionSnapshot <int>(new IInstruction <int> [0]);
            var context = CreateContext(InstructionExecutionCounter.Default);

            Assert.Throws <IllegalExecutionError>(
                () => sut.ExecuteStep(context));
        }
Beispiel #2
0
        public void ExecuteStep_ExecutionLimitReached_Throws()
        {
            var sut = new ExecutionSnapshot <int>(new IInstruction <int> [0]);
            var executionCounter = new InstructionExecutionCounter(5, 5);
            var context          = CreateContext(executionCounter);

            Assert.Throws <ExecutionLimitReachedError>(
                () => sut.ExecuteStep(context));
        }
        public void AfterProgramExecution_BoardIsAsExpected()
        {
            var startState    = string.Join(null, _startState);
            var currentState  = _contextFactory.CreateInitialState(3, 3, startState, c => c);
            var instructions  = _instructionFactory.CreateInstructionStack(Program);
            var snapshot      = new ExecutionSnapshot <char>(instructions);
            var expectedState = string.Join(null, _expected);
            var expectedBoard = _contextFactory.CreateBoard(3, expectedState, EntryConverter);
            var verifier      = new BoardVerifier <char>(expectedBoard, EntryComparer);

            while (!snapshot.ExecutionFinished(currentState))
            {
                snapshot.ExecuteStep(currentState);
            }

            var result = verifier.Verify(currentState.Board);

            result.ShouldBeTrue();
        }