internal GameFacade()
 {
     this.players = new TxtFileRepository<Player>(GlobalConstants.TopScorePath);
     this.games = new TxtFileRepository<Game>(GlobalConstants.GamesPath);
     this.field = new GameField(GlobalConstants.DefaultLevelRows, GlobalConstants.DefaultLevelCols);
     this.reader = ConsoleReader.Instance;
     this.printer = ConsoleGamePrinter.Instance;
 }
 public GameEngineTests()
 {
     this.field = new GameField(GlobalConstants.DefaultLevelRows, GlobalConstants.DefaultLevelCols);
     this.game = new Game(this.field);
     this.gameLogic = new GameLogicProvider(this.game);
     this.mockPrinter = new MockIPrinter().MockPrinter.Object;
     this.topScoreController = new MockITopScoreController().MockTopScoreController.Object;
     this.gamesController = new MockIGamesController().MockGamesController.Object;
     this.gamesRepo = new MockIGenericRepository<Game>(this.GenerateFakeCollectionOfGames());
     this.playersRepo = new MockIGenericRepository<Player>(this.GenerateFakeCollectionOfPlayers());
     this.db = new BalloonsData(this.playersRepo.MockedRepo.Object, this.gamesRepo.MockedRepo.Object);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="GameEngine"/> class.
        /// </summary>
        /// <param name="gameLogic">The logic of the game.</param>
        /// <param name="printer">The printer of the game.</param>
        /// <param name="reader">The reader of the input of the game.</param>
        /// <param name="db">The database of the game.</param>
        /// <param name="topScoreController">The controller of the top scores.</param>
        /// <param name="gamesController">The controller of the game.</param>
        public GameEngine(IGameLogicProvider gameLogic, IGamePrinter printer, IReader reader, IBalloonsData db, ITopScoreController topScoreController, IGamesController gamesController)
        {
            this.GameLogic = gameLogic;
            this.Printer = printer;
            this.Reader = reader;
            this.DataBase = db;
            this.TopScoreController = topScoreController;
            this.GamesController = gamesController;

            this.Context = new Context(this.DataBase, this.GameLogic, this.Printer, this.Reader, this.TopScoreController, this.GamesController);
            this.Factory = new CommandFactory();
            this.CommandValidator = new CommandValidator<CommandType>();
        }
        public MockIContext()
        {
            this.field = new GameField(GlobalConstants.DefaultLevelRows, GlobalConstants.DefaultLevelCols);
            this.game = new Game(this.field);
            this.gameLogic = new GameLogicProvider(this.game);
            this.mockPrinter = new MockIPrinter().MockPrinter.Object;
            this.mockReader = new MockIReader("default").MockReader.Object;
            this.topScoreController = new MockITopScoreController().MockTopScoreController.Object;
            this.gamesController = new MockIGamesController().MockGamesController.Object;
            this.gamesRepo = new MockIGenericRepository<Game>(this.GenerateFakeCollectionOfGames());
            this.playersRepo = new MockIGenericRepository<Player>(this.GenerateFakeCollectionOfPlayers());
            this.db = new BalloonsData(this.playersRepo.MockedRepo.Object, this.gamesRepo.MockedRepo.Object);

            this.MockContext = new Mock<IContext>();
            this.MockContext.SetupGet(x => x.DataBase).Returns(this.db);
            this.MockContext.SetupGet(x => x.GameLogic).Returns(this.gameLogic);
            this.MockContext.SetupGet(x => x.GamesController).Returns(this.gamesController);
            this.MockContext.SetupGet(x => x.TopScoreController).Returns(this.topScoreController);
            this.MockContext.SetupGet(x => x.Memory).Returns(new GameStateMemory());
            this.MockContext.SetupGet(x => x.Printer).Returns(this.mockPrinter);
            this.MockContext.SetupGet(x => x.Reader).Returns(this.mockReader);
        }
Beispiel #5
0
 public GameRunner(IGameManager gameManager, IGamePrinter gamePrinter, IUserInputProvider userInputProvider)
 {
     _gameManager       = gameManager ?? throw new ArgumentNullException(nameof(gameManager));
     _gamePrinter       = gamePrinter ?? throw new ArgumentNullException(nameof(gamePrinter));
     _userInputProvider = userInputProvider ?? throw new ArgumentNullException(nameof(userInputProvider));
 }