Esempio n. 1
0
        public void GetLetterFromAlphabetPosition_WhenValidPositionProvided_ExpectCorrectLetterToBeReturned()
        {
            // Arrange
            _returnedLetter = "C";

            // Act
            var result = AlphabetHelper.GetLetterFromAlphabetPosition(3);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(_returnedLetter, result);
        }
Esempio n. 2
0
 public void GetLetterFromAlphabetPosition_WhenPositionIsGreaterThanTwentySix_ExpectArgumentOutOfRangeExcpetion()
 {
     // Act
     try
     {
         var result = AlphabetHelper.GetLetterFromAlphabetPosition(27);
     }
     catch (ArgumentException ex)
     {
         // Assert
         Assert.IsInstanceOfType(ex, typeof(ArgumentOutOfRangeException));
         throw ex;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Constructor
        /// Initialises a new Grid with the expected parameters and sets up Grid Cells with references
        /// </summary>
        /// <param name="columns"></param>
        /// <param name="rows"></param>
        public Grid(int columns, int rows)
        {
            Condition.Requires(columns);
            Condition.Requires(rows);

            Cells = new GridCell[columns, rows];

            for (int c = 0; c < columns; c++)
            {
                for (int r = 0; r < rows; r++)
                {
                    var xref   = c + 1; // Not zero indexed
                    var yref   = AlphabetHelper.GetLetterFromAlphabetPosition(r + 1).ToString();
                    var status = GridCellStatus.OpenSea;

                    Cells[c, r] = new GridCell(xref, yref, status);
                }
            }
        }