Sudoque.Game.Engine.Rules.ActualsCollide.HelpWith C# (CSharp) Méthode

HelpWith() public méthode

public HelpWith ( IEnumerable cells ) : Hint
cells IEnumerable
Résultat Hint
        public Hint HelpWith(IEnumerable<Cell> cells)
        {
            var cellList = cells.ToList();
            foreach (var actual in Enumerable.Range(1, 9))
            {
                var count = cellList.Count(c => c.Actual.HasValue && c.Actual.Value == actual);
                if (count > 1)
                {
                    var hintText = string.Format("Two of the cells in this group are {0}, you nit.", actual);
                    return new Hint(hintText, cellList.Select(c => c.Id));
                }
            }
            return Hint.None;
        }

Usage Example

        public void ShouldTellUsIfTwoActualsInAGroupAreTheSame()
        {
            // Given a group containing two cells with the same actuals
            var cells = CreateCellsWithActuals(2, 3, 4, 5, 6, 7, 8, 9, 9).ToList();

            // When we ask the rule to help
            var rule = new ActualsCollide();
            var hint = rule.HelpWith(cells);

            // Then it should tell us about the two cells and contain all 9 cells
            Assert.IsTrue(hint.Text.Contains("Two of the cells"));
            Assert.IsTrue(hint.Text.Contains("9"));

            CollectionAssert.AreEquivalent(hint.CellIds, cells.Select(c => c.Id));
        }
All Usage Examples Of Sudoque.Game.Engine.Rules.ActualsCollide::HelpWith
ActualsCollide