public void TestCreateRandomBoard(int sideLength) { BoardMaker maker = new BoardMaker(); maker.LoadRandomBoard(sideLength); var board = maker.GetBoard(); board.Chars.Length.Should().Be(sideLength * sideLength); }
/// <summary> /// Manager that will handle running the game cmdline options and return a status code to the caller. /// </summary> /// <param name="opts">CmdLineOptions object that contains the parsed command line args.</param> /// <returns>Error Code. 0 = Success, 1 = Failure.</returns> public static async Task<int> RunAndReturnExitCodeAsync(CmdLineOptions opts) { if (opts == null) { throw new ArgumentNullException(nameof(opts)); } RuntimeTimer.RegisterAppStart(); m_cmdLineOpts = opts; // Validate Input ValidateCmdLine val = new ValidateCmdLine(); val.IsCmdLineValid(opts); // Load the dictionary from disk await LoadDictFromDiskAsync(); await Task.Run(() => { BoardMaker maker = new BoardMaker(); maker.LoadRandomBoard(opts.SideLength); Board board = maker.GetBoard(); IGameSolver solver = null; if (m_cmdLineOpts.Singlethreaded) { solver = new SinglethreadedGameSolverService(); } else { solver = new AsyncGameSolverService(); } var foundWords = solver.Solve(m_wordDict, board); // This is a little odd. I want to stop timing before I write all the words, which takes a long time RuntimeTimer.RegisterAppEnd(); var totalOperations = solver.GetTotalOperations(); PrintFoundWordsToConsole(foundWords, totalOperations, opts.ForceWriteFoundWords); }); return Utils.Consts.c_exitCodeSuccess; }