コード例 #1
0
        public void PassingEmptyMatrixToFillMethodShouldNotBeEmptyAfterThat()
        {
            var matrix = new Balloon[5, 5];
            var filler = new Filler(new BalloonsFactory());

            filler.Fill(matrix);

            Assert.IsNotNull(matrix[1, 1]);
        }
コード例 #2
0
        public void FillMethodShouldFillGmaeFieldWithBalloons()
        {
            var field = new GameField(FieldValidRows, FieldValidColumns);
            var filler = new Filler(new BalloonsFactory());
            field.Filler = filler;

            field.Fill();
            var balloon = field[1, 1];

            Assert.IsInstanceOfType(balloon, typeof(Balloon));
        }
コード例 #3
0
        public void RenderGameFieldWhenPassedFieldHavingNonNullCellsShouldWriteOnConsole()
        {
            var mockConsole = new Mock<IConsoleWriter>();
            var console = mockConsole.Object;

            var renderer = new ConsoleRenderer(console);
            var field = new GameField(2, 2);
            var filler = new Filler(new BalloonsFactory());
            field.Filler = filler;
            field.Fill();

            renderer.RenderGameField(field);

            mockConsole.Verify(c => c.Write(It.IsAny<string>()), Times.AtLeastOnce);
        }
コード例 #4
0
        /// <summary>
        /// This method instantiate all dependencies for the game.
        /// </summary>
        public static void StartGame()
        {
            // Console context dependancies
            IConsoleWriter consoleWriter = new ConsoleWriter();
            IConsoleReader consoleReader = new ConsoleReader();

            // Instantiate game dependancies
            IRenderer renderer = new ConsoleRenderer(consoleWriter);
            IInputHandler inputHandler = new ConsoleInputHandler(consoleWriter, consoleReader);
            IFieldFactory fieldFactory = new GameFieldFactory();
            IFieldMemoryManager fieldMemoryManager = new FieldMemoryManager();
            IBalloonsFactory balloonsFactory = new BalloonsFactory();
            IFiller matrixFiller = new Filler(balloonsFactory);
            ICommandManager commandManager = new CommandManager();

            // Printing initial screen goes here.
            renderer.RenderGameMessage(GameMessages.InitialGameMessage);
            renderer.RenderCommands(GameMessages.CommandsMessages);

            // Getting mode and difficulty goes here.
            GameMode gameMode = inputHandler.GetGameMode();
            GameDifficulty gameDifficulty = inputHandler.GetGameDifficulty();

            var reorderStrategy = GetReorderStrategy(gameMode);

            // Fluent interface implementation
            IBalloonsEngine engine = new BalloonsGameEngine()
                .Renderer(renderer)
                .Input(inputHandler)
                .FieldFactory(fieldFactory)
                .FieldMemoryManager(fieldMemoryManager)
                .BalloonsFactory(balloonsFactory)
                .CommandManager(commandManager)
                .ReorderBalloonsStrategy(reorderStrategy)
                .GameFieldFiller(matrixFiller);

            engine.InitializeGame(gameDifficulty);
            engine.StartGame();
        }
コード例 #5
0
        public void GameFieldFillerShouldNotBeNullWhenPassed()
        {
            var field = new GameField(FieldValidRows, FieldValidColumns);
            var filler = new Filler(new BalloonsFactory());

            field.Filler = filler;
            var actualFiller = field.Filler;

            Assert.IsNotNull(actualFiller);
        }