コード例 #1
0
        public void ShouldReturnFalse_CompareContextOfOriginalAndClonedInstances()
        {
            Cell firstCell = new Cell();
            firstCell.Content = 1;
            Cell secondCell = firstCell.Clone() as Cell;
            secondCell.Content = 2;

            Assert.IsFalse(firstCell.Content == secondCell.Content);
        }
コード例 #2
0
        /// <summary>
        /// This method fill the list of elements in puzzle field.
        /// </summary>
        public void FillPuzzleBody()
        {
            Cell singleCell = new Cell();
            int currentValue = 1;

            for (int row = 0; row < this.MatrixSize; row++)
            {
                for (int col = 0; col < this.MatrixSize; col++)
                {
                    // Prototype design pattern.
                    Cell currentCell = singleCell.Clone() as Cell;

                    if (currentValue == this.MatrixSize * this.MatrixSize)
                    {
                        currentValue = 0;
                    }

                    currentCell.Content = currentValue;
                    currentCell.Row = row;
                    currentCell.Col = col;
                    this.Body.Add(currentCell);
                    currentValue++;
                }
            }
        }