private DisplayPlayingField CreateSut([NotNull] IHintField hintField,
                                              [NotNull] IPlayingField playingField)
        {
            var sut = new DisplayPlayingField(hintField,
                                              playingField);

            return(sut);
        }
Esempio n. 2
0
        private void CreateCommon()
        {
            IHintField hintField = m_HintFieldFactory.Create(m_MineField);

            m_PlayingField = m_PlayingFieldFactory.Create(m_MineField);

            m_UserOutput = m_UserOutputFactory.Create(hintField,
                                                      m_PlayingField);
        }
Esempio n. 3
0
 public UserOutput([NotNull] IConsole console,
                   [NotNull] IDisplayPlayingFieldFactory factory,
                   [NotNull] IHintField hintField,
                   [NotNull] IPlayingField playingField)
 {
     m_Console = console;
     m_DisplayPlayingFieldField = factory.Create(hintField,
                                                 playingField);
 }
Esempio n. 4
0
 public UserOutput([NotNull] IConsole console,
                   [NotNull] Func <IHintField, IPlayingField, IDisplayPlayingField> factory,
                   [NotNull] IHintField hintField,
                   [NotNull] IPlayingField playingField)
 {
     m_Console = console;
     m_DisplayPlayingFieldField = factory(hintField,
                                          playingField);
 }
        private void CreateCommon()
        {
            HintField = m_HintFieldFactory(m_MineField); // todo test setting field

            m_PlayingField = m_PlayingFieldFactory(m_MineField);

            m_UserOutput = m_UserOutputFactory(HintField,
                                               m_PlayingField);
        }
Esempio n. 6
0
        public override List <Square> TrySolve(IPlayingField field)
        {
            _field = field;

            var modifiedSquares = new List <Square>();

            SetSingleOccurance(field.GetRow, modifiedSquares);
            SetSingleOccurance(field.GetColumn, modifiedSquares);
            SetSingleOccurance(field.GetBigSquare, modifiedSquares);

            return(modifiedSquares.Distinct().ToList());
        }
        public override List <Square> TrySolve(IPlayingField field)
        {
            var run             = true;
            var modifiedSquares = new List <Square>();

            while (run)
            {
                run = false;

                FilterCandidates(field.GetRow, ref run, modifiedSquares);
                FilterCandidates(field.GetColumn, ref run, modifiedSquares);
                FilterCandidates(field.GetBigSquare, ref run, modifiedSquares);

                foreach (var square in modifiedSquares.Where(x => x.Candidates.Count == 1)) //todo: && value == 0, but how to test? guess I could extract interface for square and verify
                {
                    square.Value = square.Candidates[0];
                }
            }

            return(modifiedSquares.Distinct().ToList());
        }
Esempio n. 8
0

        
 private IUserOutput UserOutputFactory(
     IHintField hintField,
     IPlayingField playingField)
 {
     return(m_UserOutput);
 }
 public DisplayPlayingField([NotNull] IHintField hintField,
                            [NotNull] IPlayingField playingField)
 {
     m_HintField    = hintField;
     m_PlayingField = playingField;
 }
Esempio n. 11
0
 protected PlayingFieldTests()
 {
     _field = new PlayingField(FieldDefinition);
 }
Esempio n. 12
0
 private IDisplayPlayingField DisplayPlayingFieldFactory(
     IHintField hintField,
     IPlayingField playingField)
 {
     return(m_DisplayPlayingField);
 }