public void ConnectivityTest() { const int height = 3; const int width = 4; var labyrinth = new Labyrinth(height, width); for (var i = 0; i < height; i++) { for (var j = 0; j < width; j++) { var connectedCells = GetConnectedCells(height, width, labyrinth, new Tuple <int, int>(i, j)); foreach (var connectedCell in connectedCells) { Assert.IsTrue(labyrinth.AreConnected(i, j, connectedCell.Item1, connectedCell.Item2)); } } } Assert.IsFalse(labyrinth.AreConnected(-1, -1, 1, 1)); Assert.IsFalse(labyrinth.AreConnected(1, 1, -1, -1)); }
private HashSet <Tuple <int, int> > GetConnectedCells(int height, int width, Labyrinth labyrinth, Tuple <int, int> cell) { var connectedCells = new HashSet <Tuple <int, int> >(); for (var i = 0; i < height; i++) { for (var j = 0; j < width; j++) { if (labyrinth.AreConnected(i, j, cell.Item1, cell.Item2)) { connectedCells.Add(new Tuple <int, int>(i, j)); } } } return(connectedCells); }