public void Should_Count_Neighbours_mine_cells(string input, string excpectedInOutput) { TextReader reader = new StringReader(input); var minesweeper = Minesweeper.Parse(reader); var firstField = minesweeper.Fields.First(); Assert.That(firstField.GetSolution(), Does.Contain(excpectedInOutput)); }
public void Should_Parse_firstline_as_fieldsize(string input, int height, int width) { var minesweeper = Minesweeper.Parse(input.ToReader()); var firstField = minesweeper.Fields.First(); Assert.AreEqual(height, firstField.Height); Assert.AreEqual(width, firstField.Width); }
public void Should_Parse_dot_char_as_clear_cell() { var input = "1 1\r\n.0 0"; TextReader reader = new StringReader(input); var minesweeper = Minesweeper.Parse(reader); var firstField = minesweeper.Fields.First(); Assert.That(firstField.GetSolution(), Does.Contain("0")); }
public static Minesweeper Parse(TextReader reader) { var minesweeper = new Minesweeper(); while (reader.Peek() != -1) { minesweeper.ParseField(reader); } return(minesweeper); }
public void Should_Return_fieldNumber_has_header_of_each_solution() { var input = @"4 4 *... .... .*.. .... 3 5 **... ..... .*... 0 0"; var minesweeper = Minesweeper.Parse(input.ToReader()); Assert.That(minesweeper.GetSolution(), Does.StartWith("Field #1:" + Environment.NewLine)); Assert.That(minesweeper.GetSolution(), Does.Contain("Field #2:" + Environment.NewLine)); }
public void Should_Parse_Expected_number_of_fields() { var input = @"4 4 *... .... .*.. .... 3 5 **... ..... .*... 0 0"; var minesweeper = Minesweeper.Parse(input.ToReader()); Assert.AreEqual(2, minesweeper.Fields.Count()); }