Example #1
0
        public void EmptyMatrix()
        {
            var matrix =
                new StringBuilder()
                    .AppendLine("          ")
                    .AppendLine("          ")
                    .AppendLine("          ")
                    .AppendLine("          ")
                    .AppendLine("          ")
                    .AppendLine("          ")
                    .AppendLine("          ")
                    .AppendLine("          ")
                    .AppendLine("          ")
                    .AppendLine("          ");

            var result = new ReachMatrixBuilder().Build(ToInts(matrix), 0, 0);

            var expectedResult =
                new StringBuilder()
                    .AppendLine("**********")
                    .AppendLine("**********")
                    .AppendLine("**********")
                    .AppendLine("**********")
                    .AppendLine("**********")
                    .AppendLine("**********")
                    .AppendLine("**********")
                    .AppendLine("**********")
                    .AppendLine("**********")
                    .AppendLine("**********");

            GetSure(expectedResult.ToString(), result);
        }
Example #2
0
        public void CanBeReached()
        {
            var placeHoldersMatrix = new bool[Length, Width];

            for (int i = 0; i < Length; i++)
            {
                for (int j = 0; j < Width; j++)
                {
                    placeHoldersMatrix[i, j] = Cells[i, j] != null;
                }
            }

            var reachMatrixBuilder = new ReachMatrixBuilder();

            Eat = reachMatrixBuilder.Build(placeHoldersMatrix, Eat, 0, 0);
            Eat = reachMatrixBuilder.Build(placeHoldersMatrix, Eat, 0, Width - 1);
            Eat = reachMatrixBuilder.Build(placeHoldersMatrix, Eat, Length - 1, 0);
            Eat = reachMatrixBuilder.Build(placeHoldersMatrix, Eat, Length - 1, Width - 1);
        }