예제 #1
0
        /// <summary>
        /// Starts a new console game.
        /// </summary>
        internal void Start()
        {
            this.balloonsGame = new Game(this.field);
            this.gameLogic = new GameLogicProvider(this.balloonsGame);
            this.data = new BalloonsData(this.players, this.games);
            this.topScoreController = new TopScoreController(this.data.Players);
            this.gamesController = new GamesController(this.data.Games);
            this.engine = new GameEngine(this.gameLogic, this.printer, this.reader, this.data, this.topScoreController, this.gamesController);

            this.engine.StartGame();
        }
 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);
 }
예제 #3
0
        /// <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);
        }