/// <summary> /// Constructor /// Initialises a new Grid Cell with the expected parameters /// </summary> /// <param name="xref"></param> /// <param name="yref"></param> /// <param name="status"></param> public GridCell(int xref, string yref, GridCellStatus status) { Condition.Requires(xref).IsGreaterOrEqual(1); Condition.Requires(AlphabetHelper.GetAlphabetPositionOfLetter(yref)).IsGreaterOrEqual(1); XRef = xref; YRef = yref; Status = status; HorizontalBoatCapacity = 0; VerticalBoatCapacity = 0; }
public void GetAlphabetPositionOfLetter_WhenValidLetterProvided_ExpectCorrectPositionToBeReturned() { // Arrange _returnedPosition = 18; // Act var result = AlphabetHelper.GetAlphabetPositionOfLetter("R"); // Assert Assert.IsNotNull(result); Assert.AreEqual(_returnedPosition, result); }
public void GetAlphabetPositionOfLetter_WhenLetterIsEmpty_ExpectFormatException() { // Act try { var result = AlphabetHelper.GetAlphabetPositionOfLetter(String.Empty); } catch (FormatException ex) { // Assert Assert.IsInstanceOfType(ex, typeof(FormatException)); throw ex; } }
public void GetAlphabetPositionOfLetter_WhenLetterIsWhiteSpace_ExpectArgumentException() { // Act try { var result = AlphabetHelper.GetAlphabetPositionOfLetter(" "); } catch (FormatException ex) { // Assert Assert.IsInstanceOfType(ex, typeof(FormatException)); throw ex; } }
public void GetAlphabetPositionOfLetter_WhenLetterIsNull_ExpectArgumentNullException() { // Act try { var result = AlphabetHelper.GetAlphabetPositionOfLetter(null); } catch (ArgumentException ex) { // Assert Assert.IsInstanceOfType(ex, typeof(ArgumentNullException)); throw ex; } }