Example #1
0
        static void Main(string[] args)
        {
            //Initialize Service Providers (Dependency Injection)
            var serviceProvider = new ServiceCollection()
                                  .AddSingleton <ITicTacToeService, TicTacToeService>()
                                  .AddSingleton <ITicTacToeRandomService, TicTacToeRandomService>()
                                  .BuildServiceProvider();

            //Get instance of TicTacToeService to be used throughout (injectable)
            _ticTacToeService       = serviceProvider.GetService <ITicTacToeService>();
            _ticTacToeRandomService = serviceProvider.GetService <ITicTacToeRandomService>();

            //Initialize Noughts and Crosses
            InitializeTicTacToe(3);

            //Indicate user the game has finished!
            Console.WriteLine();
            Console.WriteLine("Thank you for using Noughts and Crosses!!");
            Console.WriteLine();
        }
Example #2
0
 public void Setup()
 {
     _ticTacToeService       = new TicTacToeService();
     _ticTacToeRandomService = new TicTacToeRandomService(_ticTacToeService);
 }