예제 #1
0
        public void GetAllUnsetVariables_NoVariablesAreUnset_ReturnsEmptyCollection()
        {
            // Arrange
            var grid = new SudokuGrid(FullGrid());

            // Act
            var unsetVariables = new List <Variable>(grid.GetAllUnsetVariables());

            // Assert
            Assert.AreEqual(0, unsetVariables.Count);
        }
예제 #2
0
        public void GetAllUnsetVariables_AllVariablesAreUnset_ReturnsAllVariables()
        {
            // Arrange
            var initialValues = EmptyGrid();
            var grid          = new SudokuGrid(initialValues);

            // Act
            var unsetVariables = new List <Variable>(grid.GetAllUnsetVariables());

            // Assert
            Assert.AreEqual(initialValues.Cells, unsetVariables.Count);
            Assert.IsTrue(unsetVariables.All(v => !v.IsSet));
        }
예제 #3
0
        public void GetAllUnsetVariables_SomeVariablesAreUnset_ReturnsOnlyUnsetVariables()
        {
            // Arrange
            var initialValues = AnyInitialValues();
            var grid          = new SudokuGrid(initialValues);

            // Act
            var unsetVariables = new List <Variable>(grid.GetAllUnsetVariables());

            // Assert
            int unsetCount = initialValues.Count(x => x == Variable.UNSET_VALUE);

            Assert.AreEqual(unsetCount, unsetVariables.Count);
            Assert.IsTrue(unsetVariables.All(v => !v.IsSet));
        }