public void FieldCreatorShouldMakeNewFieldIfNumberRead() { var fieldCreator = new FieldCreator(); var lineRetriever = new LineRetriever(new[] { "11", ".", "22", "..", "*.", "00" }); var allFields = fieldCreator.ReadFields(lineRetriever); Assert.Equal(2, allFields.Count); }
public void ShouldThrowExceptionIfOutOfLines() { var lineRetriever = new LineRetriever(new [] { "00" }); var line = lineRetriever.GetNextLine(); Assert.Equal("00", line); Assert.Throws <IndexOutOfRangeException>(() => lineRetriever.GetNextLine()); }
public void ShouldReturnLinesInOrder() { var lineRetriever = new LineRetriever(new [] { "22", "..", "*.", "00" }); var line = lineRetriever.GetNextLine(); Assert.Equal("22", line); line = lineRetriever.GetNextLine(); Assert.Equal("..", line); }
public void ShouldMakeArrayBasedOnFieldSize(string [] input, int rank, int length) { var fieldCreator = new FieldCreator(); var lineRetriever = new LineRetriever(input); var allFields = fieldCreator.ReadFields(lineRetriever); var fieldArray = HintFieldCalculator.ConvertToArray(allFields[0]); Assert.Equal(rank, fieldArray.Rank); Assert.Equal(length, fieldArray.Length); }
public void ShouldConvertFieldToArray() { var fieldCreator = new FieldCreator(); var lineRetriever = new LineRetriever(new [] { "22", "..", "*.", "00" }); var allFields = fieldCreator.ReadFields(lineRetriever); var hintArray = HintFieldCalculator.ConvertToArray(allFields[0]); Assert.Equal(4, hintArray.Length); Assert.Equal(CellType.Empty, hintArray[0, 0]); Assert.Equal(CellType.Empty, hintArray[0, 1]); Assert.Equal(CellType.Mine, hintArray[1, 0]); Assert.Equal(CellType.Empty, hintArray[1, 1]); }
public void ShouldMakeFieldFromFile() { var mock = new Mock <IInputReader>(); mock.Setup(input => input.ReadFile("")).Returns(new[] { "22", "..", ".*", "00" }); var fieldCreator = new FieldCreator(); var lineRetriever = new LineRetriever(mock.Object.ReadFile("")); var fields = fieldCreator.ReadFields(lineRetriever); Assert.Equal(new [] { "22", "..", ".*", "00" }, mock.Object.ReadFile("")); Assert.Equal(new List <CellType> { CellType.Empty, CellType.Empty }, fields[0].GetRow(0)); Assert.Equal(new List <CellType> { CellType.Empty, CellType.Mine }, fields[0].GetRow(1)); }