Example #1
0
        public void MapArrayOfStringToGridPanel_MapsGivenStrings_ReturnedGridModelIsCorrectlyMapped()
        {
            // arrange
            var lines = new[]
            {
                "*..",
                "..*"
            };

            // act

            IGridPanelMapper gridMapper = new GridPanelMapper();

            var actualGrid = gridMapper.MapArrayOfStringToGridPanel(lines);


            // assert

            var expectedGrid = new int[, ]
            {
                { GridPanelConstantValues.Mine, 0, 0 },

                { 0, 0, GridPanelConstantValues.Mine }
            };

            TestTool.AssertOutputs(actualGrid, expectedGrid);
        }
Example #2
0
        public void CalculateLeftAdjacent_FindsTheLeftLocationAndIncrementsTheLocationValue_SetsTheGridPanelToNewCorrectStatus()
        {
            // arrange

            var actualGrid = new int[, ]
            {
                { GridPanelConstantValues.Mine, 0, 0 },
                { 0, 0, GridPanelConstantValues.Mine }
            };

            var actualGridPanel = new GridPanel(2, 3);

            TestTool.ArrangeInputs(actualGridPanel, actualGrid);

            // act

            IAdjacentCalculator adjacentCalculator = new AdjacentCalculator(actualGridPanel);

            adjacentCalculator.CalculateLeftAdjacent(new Location {
                Row = 1, Column = 2
            });

            // assert

            var expectedGrid = new int[, ]
            {
                { GridPanelConstantValues.Mine, 0, 0 },

                { 0, 1, GridPanelConstantValues.Mine }
            };

            TestTool.AssertOutputs(actualGridPanel, expectedGrid);
        }
Example #3
0
        public void MineSweeperServie_LoadsFromFileAndCalculatAdjacents_ReturnedGridPanelIsCorrect()
        {
            // arrange

            var gridPanel = TestTool.GetGridPanel("feld1.txt");

            // act

            IMineSweeperService meinSweeperService = new MineSweeperService(new AdjacentCalculator(gridPanel));

            meinSweeperService.CalculateAdjacentValues(gridPanel);

            // assert

            var expectedGrid = new int[, ]
            {
                { GridPanelConstantValues.Mine, GridPanelConstantValues.Mine, 1, 0, 0 },
                { 3, 3, 2, 0, 0 },
                { 1, GridPanelConstantValues.Mine, 1, 0, 0 },
            };


            TestTool.AssertOutputs(gridPanel, expectedGrid);
        }