public void FindOneResult_CheckDirectionTest(string populateText, string searchFor, CellDirection expectedDirection)
        {
            var grid    = new StringSearchGrid(populateText);
            var results = grid.Find(searchFor);

            results.First().Direction.Should().Be(expectedDirection);
        }
        public void GridContainsTest(string populateText, string searchFor, bool expectedContains)
        {
            var  grid   = new StringSearchGrid(populateText);
            bool result = grid.Contains(searchFor);

            result.Should().Be(expectedContains);
        }
        public void FindOneResult_CheckValueTest(string populateText, string searchFor)
        {
            var grid    = new StringSearchGrid(populateText);
            var results = grid.Find(searchFor);

            results.First().Value.Should().Be(searchFor);
        }
Example #4
0
        public void Populate_GetCellForOutOfRangeReturnsNull(string populateText, int getRow, int getCol)
        {
            var grid = new StringSearchGrid(populateText);
            var cell = grid.GetCell(getRow, getCol);

            cell.Should().BeNull();
        }
Example #5
0
        public void Populate_GetValueTest(string populateText, int getRow, int getCol, char expectedValue)
        {
            var grid  = new StringSearchGrid(populateText);
            var value = grid.GetValue(getRow, getCol);

            value.Should().Be(expectedValue);
        }
Example #6
0
        public void Populate_RowColumnTest(string populateText, int expectedColumns, int expectedRows)
        {
            var grid = new StringSearchGrid(populateText);

            grid.Rows.Should().Be(expectedRows);
            grid.Columns.Should().Be(expectedColumns);
        }
Example #7
0
        public void WidthHeightConstructor_RowColumnTest(int columns, int rows)
        {
            var grid = new StringSearchGrid(columns, rows);

            grid.Rows.Should().Be(rows);
            grid.Columns.Should().Be(columns);
        }
Example #8
0
        public void Populate_GetCellTest(string populateText, int getRow, int getCol, char expectedValue)
        {
            var grid = new StringSearchGrid(populateText);
            var cell = grid.GetCell(getRow, getCol);

            cell.Should().NotBeNull();
            cell.Value.Should().Be(expectedValue);
        }
        public void ApplyStringToGridTest(string populateText, string applyString, int startRow, int startColumn, CellDirection direction, bool expectedApplied)
        {
            var  grid        = new StringSearchGrid(populateText);
            var  gridCell    = grid.GetCell(startRow, startColumn);
            bool applyResult = gridCell.Apply(applyString, direction);

            applyResult.Should().Be(expectedApplied);
            grid.Contains(applyString).Should().Be(expectedApplied);
        }
        public void CanStringBeAssignedToGridTest(string populateText, int startRow, int startColumn,
                                                  string desiredString, CellDirection direction, bool expectedCanBeAssigned)
        {
            var grid      = new StringSearchGrid(populateText);
            var startCell = grid.GetCell(startRow, startColumn);

            var canBeAssignedResult = startCell.CanBeAssigned(desiredString, direction);

            canBeAssignedResult.Should().Be(expectedCanBeAssigned);
        }
        public void FindOneResult_CheckStartCoordTest(string populateText, string searchFor, int expectedRow, int expectedColumn)
        {
            var grid    = new StringSearchGrid(populateText);
            var results = grid.Find(searchFor);

            var coord = results.First().Start;

            coord.Row.Should().Be(expectedRow);
            coord.Column.Should().Be(expectedColumn);
        }
Example #12
0
        public void SizeConstructor_AllValuesNull(int width, int height)
        {
            var grid = new StringSearchGrid(width, height);

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    grid.GetValue(y, x).Should().BeNull();
                }
            }
        }
Example #13
0
        public void DirectionTest(string populateText, int getRow, int getCol, CellDirection direction, char?expectedValue)
        {
            var grid       = new StringSearchGrid(populateText);
            var cell       = grid.GetCell(getRow, getCol);
            var resultCell = cell.GetNextCell(direction);

            if (expectedValue == null)
            {
                resultCell.Should().BeNull();
            }
            else
            {
                resultCell.Value.Should().Be(expectedValue);
            }
        }
Example #14
0
        public void GetRandomCellTest()
        {
            var grid = new StringSearchGrid("ABC\r\nDEF\r\nGHI");

            int testCount   = 100;
            var resultCells = new List <GridCell>();

            for (int i = 0; i < testCount; i++)
            {
                resultCells.Add(grid.GetRandomCell());
            }

            resultCells.Count.Should().Be(testCount);

            resultCells.All(c => c != null).Should().Be(true, "it should always return a cell");

            resultCells.Select(c => c.Value)
            .Distinct().Count()
            .Should().BeGreaterThan(1, "it should return a variety of different cells");
        }
Example #15
0
        public void GridToStringTest(string populateText)
        {
            var grid = new StringSearchGrid(populateText);

            grid.ToString().Should().Be(populateText);
        }