示例#1
0
        public void IfStartedAtTargetThenPathExists()
        {
            var       sut        = new RatInAMaze();
            const int sampleSize = 3;
            var       maze       = new int[sampleSize][];

            maze[0]    = new int[sampleSize];
            maze[0][0] = 1;
            Assert.True(sut.IsPathExists(maze, 0, 0));
        }
示例#2
0
        public void IfSurroundedByDeadEnsPathDoNotExists()
        {
            var       sut        = new RatInAMaze();
            const int sampleSize = 3;
            var       maze       = new int[sampleSize][];

            maze[0]    = new int[sampleSize];
            maze[1]    = new int[sampleSize];
            maze[2]    = new int[sampleSize];
            maze[0][0] = 1;
            Assert.False(sut.IsPathExists(maze, 2, 2));
        }
示例#3
0
        public void ComplexPath()
        {
            var sut = new RatInAMaze();

            var maze = new int[4][];

            maze[0] = new[] { 1, 0, 1, 1, 0 };
            maze[1] = new[] { 1, 1, 1, 0, 1 };
            maze[2] = new[] { 0, 1, 0, 1, 1 };
            maze[3] = new[] { 1, 1, 1, 1, 1 };

            Assert.True(sut.IsPathExists(maze, 2, 3));
        }
示例#4
0
        public void SimplePath()
        {
            var       sut        = new RatInAMaze();
            const int sampleSize = 2;
            var       maze       = new int[sampleSize][];

            maze[0]    = new int[sampleSize];
            maze[1]    = new int[sampleSize];
            maze[0][0] = 1;
            maze[0][1] = 1;
            maze[1][1] = 1;
            Assert.True(sut.IsPathExists(maze, 1, 1));
        }
        public void RateInAMazeTest()
        {
            int[,] maze = new[, ] {
                { 1, 0, 0, 0 }, { 1, 1, 0, 1 }, { 0, 1, 0, 0 }, { 1, 1, 1, 1 }
            };
            var sol = new RatInAMaze().SolveRatInAMaze(maze);

            int[] oneDimension = new int[sol.Length];
            var   i            = 0;

            foreach (var item in sol)
            {
                oneDimension[i++] = item;
            }
            Assert.AreEqual("1,0,0,0,1,1,0,0,0,1,0,0,0,1,1,1", String.Join(",", oneDimension));
        }