public void GetUnsetNeighbors_WithAnyVariable_ReturnsUnsetVariablesInRowColumnAndSquare()
        {
            // Arrange
            var grid     = new SudokuGrid(FullGrid());
            var variable = grid[4, 5];

            var expectedVariables = new Variable[]
            {
                grid[4, 6],                 // same row
                grid[1, 5],                 // same column
                grid[3, 3],                 // same square
                grid[5, 5]                  // same column and square
            };

            foreach (var neighbor in expectedVariables)
            {
                neighbor.Unset();
            }

            // Act
            var unsetNeighbors = new List <Variable>(grid.GetUnsetNeighbors(variable));

            // Assert
            CollectionAssert.AreEquivalent(expectedVariables, unsetNeighbors);
        }
        public void GetUnsetNeighbors_VariableIsUnset_ScreensOutVariable()
        {
            // Arrange
            var grid     = new SudokuGrid(FullGrid());
            var variable = grid[0, 2];

            variable.Unset();

            var neighbors = new Variable[]
            {
                grid[0, 5],                 // same row
                grid[3, 2],                 // same column
                grid[1, 0],                 // same square
                grid[2, 2]                  // same column and square
            };

            foreach (var neighbor in neighbors)
            {
                neighbor.Unset();
            }

            // Act
            var unsetNeighbors = new List <Variable>(grid.GetUnsetNeighbors(variable));

            // Assert
            CollectionAssert.DoesNotContain(unsetNeighbors, variable);
        }
        public void GetUnsetNeighbors_WithNullVariable_ThrowsArgumentNullException()
        {
            // Arrange
            var grid = new SudokuGrid(AnyInitialValues());

            // Act
            Action action = () =>
            {
                grid.GetUnsetNeighbors(null);
            };

            // Assert
            Assert.ThrowsException <ArgumentNullException>(action);
        }