public void FileReaderShouldBeAbleToOpenAndReadFileAndReturnFinalMinefieldsWithMines2() { string filePath = Path.Combine(Environment.CurrentDirectory, "Mines2.csv"); var fileHandler = new FileReader(filePath); var minefieldScorer = new MinefieldScorer(fileHandler); minefieldScorer.Run(); var result = minefieldScorer.PrintMinefield(); var expected = "\n" + "\n" + "**\n" + "33\n" + "2*\n" + "*2\n" + "11\n" + "11\n" + "*1\n" + "\n" + "\n" + "\n" ; Assert.Equal(expected, result); }
public void MultipleMinefieldsShouldBeHandled() { IEnumerable <string> fileContent = new[] { "33", "...", "...", "...", "", "12", "*." }; var ioReader = new TestReader(fileContent); var minefieldScorer = new MinefieldScorer(ioReader); minefieldScorer.Run(); var result = minefieldScorer.PrintMinefield(); var expected = new[] { "000", "000", "000", "", "*1" }; Assert.Equal(string.Join("\n", expected), result); }
public void ReturnEmptyStringIfRowsAndColumnsAreZero() { var fileContent = new[] { "00" }; var ioReader = new TestReader(fileContent); var minefieldScorer = new MinefieldScorer(ioReader); minefieldScorer.Run(); var result = minefieldScorer.PrintMinefield(); var expected = ""; Assert.Equal(expected, result); }
public void FileReaderShouldBeAbleToOpenAndReadFileAndReturnFinalMinefieldsWithSingleMinefield() { string fileLocation = Path.Combine(Environment.CurrentDirectory, "SingleMinefield.csv"); var fileHandler = new FileReader(fileLocation); var minefieldScorer = new MinefieldScorer(fileHandler); minefieldScorer.Run(); var result = minefieldScorer.PrintMinefield(); var expected = "*100\n" + "2210\n" + "1*10\n" + "1110"; Assert.Equal(expected, result); }
public void AllScoreAreZeroWhenThereAreNoMines() { IEnumerable <string> fileContent = new[] { "33", "...", "...", "..." }; var ioReader = new TestReader(fileContent); var minefieldScorer = new MinefieldScorer(ioReader); minefieldScorer.Run(); var result = minefieldScorer.PrintMinefield(); var expected = "000\n" + "000\n" + "000"; Assert.Equal(expected, result); }
public void ScoreOnlyInOneCornerWhenMinesAllAroundThePerimeterIn2X2Minefield() { var fileContent = new[] { "22", "**", "*." }; var ioReader = new TestReader(fileContent); var minefieldScorer = new MinefieldScorer(ioReader); minefieldScorer.Run(); var result = minefieldScorer.PrintMinefield(); var expected = "**\n" + "*3"; Assert.Equal(expected, result); }
public void ScoresAllAroundPerimeterWhenOneMineInACornerIn2X2Minefield() { var fileContent = new[] { "22", ".*", ".." }; var ioReader = new TestReader(fileContent); var minefieldScorer = new MinefieldScorer(ioReader); minefieldScorer.Run(); var result = minefieldScorer.PrintMinefield(); var expected = "1*\n" + "11"; Assert.Equal(expected, result); }
public void NoScoresWhenThereAreAllMinesFor2X2Minefield() { var fileContent = new[] { "22", "**", "**" }; var ioReader = new TestReader(fileContent); var minefieldScorer = new MinefieldScorer(ioReader); minefieldScorer.Run(); var result = minefieldScorer.PrintMinefield(); var expected = "**\n" + "**"; Assert.Equal(expected, result); }
public void AllScoreAreZeroWhenThereAreNoMinesFor2X2Minefield() { var fileContent = new[] { "22", "..", ".." }; var ioReader = new TestReader(fileContent); var minefieldScorer = new MinefieldScorer(ioReader); minefieldScorer.Run(); var result = minefieldScorer.PrintMinefield(); var expected = "00\n" + "00"; Assert.Equal(expected, result); }
public void ScoreOnlyInMiddleWhenMinesAllAroundThePerimeter() { var fileContent = new[] { "33", "***", "*.*", "***" }; var ioReader = new TestReader(fileContent); var minefieldScorer = new MinefieldScorer(ioReader); minefieldScorer.Run(); var result = minefieldScorer.PrintMinefield(); var expected = "***\n" + "*8*\n" + "***"; Assert.Equal(expected, result); }
public void CheckIfCorrectScoreIfAllMinesAreDifferentSizeColumnAndRow() { var fileContent = new[] { "35", "**...", ".....", "**..." }; var ioReader = new TestReader(fileContent); var minefieldScorer = new MinefieldScorer(ioReader); minefieldScorer.Run(); var result = minefieldScorer.PrintMinefield(); var expected = "**100\n" + "44200\n" + "**100"; Assert.Equal(expected, result); }