コード例 #1
0
        public void DoAction_ShouldCallActionHandler()
        {
            var actionHandler = A.Fake <IVacuumWorldActionHandler>();
            var vacuumWorld   = new VacuumWorld(new VacuumWorldState(3), actionHandler);
            const VacuumWorldAction action = VacuumWorldAction.Up;

            vacuumWorld.DoAction(action);

            A.CallTo(() => actionHandler.DoAction(A <VacuumWorldState> ._, action)).MustHaveHappened();
        }
コード例 #2
0
        private static void InteractivelyDisplaySolution(
            VacuumWorldState initialState,
            IEnumerable <VacuumWorldAction> solution)
        {
            var renderer = new Renderer();
            var machine  = new VacuumWorld(initialState,
                                           VacuumWorldActionHandler.CreateDeterministicActionHandler());

            foreach (var action in solution)
            {
                renderer.Render(machine.State);
                var key = Console.ReadKey();
                if (key.Key == ConsoleKey.Escape)
                {
                    break;
                }
                machine.DoAction(action);
            }

            renderer.Render(machine.State);
        }