//testable main public static void Run(IEnumerable<string> args, ITextDiscriminator textDiscriminator, IConsoleFacade console, IStateMachine player, IInformationDisplayer informationDisplayer) { //once off construction of input from execution args string input = String.Empty; if (args != null) foreach (String s in args) input += s + " "; //main loop bool exit = false; while (!exit) { foreach (ICommand command in textDiscriminator.Interpret(input.Trim())) { //ignore if (command.CommandType == CommandType.Ignore) continue; //quit if ((command.CommandType == CommandType.Exit) || ((command.CommandType == CommandType.Stop) && (player.IsStopped))) exit = true; //everything else is fair game informationDisplayer.ProcessCommand(command); player.ProcessCommand(command); } if (!exit) input = console.ReadLine(); } }
public override void SetUp() { textDiscriminator = CreateMock<ITextDiscriminator>(); console = CreateMock<IConsoleFacade>(); player = CreateMock<IStateMachine>(); informationDisplayer = CreateMock<IInformationDisplayer>(); }
public override void SetUp() { _commandFactory = CreateMock<ICommandFactory>(); _searchQueryFactory = CreateMock<ISearchQueryFactory>(); _textDiscriminator = new TextDiscriminator(_commandFactory, _searchQueryFactory); _searchQuery = Stub<ISearchQuery>(); }