Beispiel #1
0
        public void TurningFaceClockwise_Moves1RowOfStickersOnAdjacentSides()
        {
            var cube = new Cube();

            Assert_IsSolved(cube);

            cube = cube.Apply(Turn.Parse("U"));

            Assert.Equal(Side.Right, cube[MovablePosition.Get(Side.Front, Side.Up)]);
            Assert.Equal(Side.Right, cube[MovablePosition.Get(Side.Front, Side.Up | Side.Left)]);
            Assert.Equal(Side.Right, cube[MovablePosition.Get(Side.Front, Side.Up | Side.Right)]);

            Assert.Equal(Side.Back, cube[MovablePosition.Get(Side.Right, Side.Up)]);
            Assert.Equal(Side.Back, cube[MovablePosition.Get(Side.Right, Side.Up | Side.Front)]);
            Assert.Equal(Side.Back, cube[MovablePosition.Get(Side.Right, Side.Up | Side.Back)]);

            Assert.Equal(Side.Left, cube[MovablePosition.Get(Side.Back, Side.Up)]);
            Assert.Equal(Side.Left, cube[MovablePosition.Get(Side.Back, Side.Up | Side.Right)]);
            Assert.Equal(Side.Left, cube[MovablePosition.Get(Side.Back, Side.Up | Side.Left)]);

            Assert.Equal(Side.Front, cube[MovablePosition.Get(Side.Left, Side.Up)]);
            Assert.Equal(Side.Front, cube[MovablePosition.Get(Side.Left, Side.Up | Side.Back)]);
            Assert.Equal(Side.Front, cube[MovablePosition.Get(Side.Left, Side.Up | Side.Front)]);

            Assert.False(cube.IsSolved);
        }
        public void SideHas9Squares(Side side)
        {
            var squares = MovablePosition.GetMovablePositionsForSide(side);

            Assert.Equal(8, squares.Length);

            // Center
            Assert.Equal(0, squares.Count(MovablePosition.IsCenter));

            // Edges
            MovablePosition[] edges = squares.Where(MovablePosition.IsEdge).ToArray();
            Assert.Equal(4, edges.Length);
            var adjacents = CubeGeometry.GetClockwiseAdjacentFaces(side);

            foreach (var adjacent in adjacents)
            {
                Assert.Contains(MovablePosition.Get(side, adjacent), edges);
            }

            // Corners
            MovablePosition[] corners = squares.Where(MovablePosition.IsCorner).ToArray();
            Assert.Equal(4, corners.Length);
            for (int i = 0; i < 4; ++i)
            {
                Assert.Contains(MovablePosition.Get(side, adjacents[i] | adjacents[(i + 1) % 4]), corners);
            }
        }