public void TestCase3x3() { var sol = new FloodFillSolution(); var img = new[] { new [] { 1, 1, 1 }, new [] { 1, 1, 0 }, new [] { 1, 0, 1 } }; sol.FloodFill(img, 1, 1, 2); var expected = new[] { new [] { 2, 2, 2 }, new [] { 2, 2, 0 }, new [] { 2, 0, 1 } }; Assert.AreEqual(expected.Length, img.Length); for (int i = 0; i < expected.Length; i++) { CollectionAssert.AreEqual(expected[0], img[0]); } }
public void FindJudge_Test() { //Arrange FloodFillSolution solution = new FloodFillSolution(); var image1 = new int[][] { new int[] { 1, 1, 1 }, new int[] { 1, 1, 0 }, new int[] { 1, 0, 1 } }; var image2 = new int[][] { new int[] { 0, 0, 0 }, new int[] { 0, 0, 0 }, new int[] { 0, 0, 0 } }; var output1 = new int[][] { new int[] { 2, 2, 2 }, new int[] { 2, 2, 0 }, new int[] { 2, 0, 1 } }; var output2 = new int[][] { new int[] { 2, 2, 2 }, new int[] { 2, 2, 2 }, new int[] { 2, 2, 2 } }; //Act var result1 = solution.FloodFill(image1, 1, 1, 2); var result2 = solution.FloodFill(image2, 0, 0, 2); //Assert Assert.AreEqual(output1, result1); Assert.AreEqual(output2, result2); }
public void AvoidInfiniteLoop() { var sol = new FloodFillSolution(); var img = new[] { new [] { 0, 0, 0 }, new [] { 0, 1, 1 } }; sol.FloodFill(img, 1, 1, 1); var expected = new[] { new [] { 0, 0, 0 }, new [] { 0, 1, 1 } }; Assert.AreEqual(expected.Length, img.Length); for (int i = 0; i < expected.Length; i++) { CollectionAssert.AreEqual(expected[0], img[0]); } }
public void ShouldThrowWhenNullImage() { var sol = new FloodFillSolution(); sol.FloodFill(null, 0, 0, 0); }