Пример #1
0
        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);
            }
        }
Пример #2
0
        void Assert_CanFindClockwiseAdjacentSidesOf(Side side)
        {
            var adjacents = CubeGeometry.GetClockwiseAdjacentFaces(side);

            Assert.Equal(4, adjacents.Length);
            var opposite = CubeGeometry.OppositeSideOf(side);

            foreach (var adjacent in adjacents)
            {
                Assert.True(adjacent != side && adjacent != opposite);
            }

            Assert_AdjacentSidesListGoAroundFaceInOrder(adjacents);
        }
Пример #3
0
        static public MovablePosition[] GetMovablePositionsForSide(Side side)
        {
            Side[] adjacents = CubeGeometry.GetClockwiseAdjacentFaces(side);

            return(new[] {
                MovablePosition.Get(side, adjacents[0]),
                MovablePosition.Get(side, adjacents[1]),
                MovablePosition.Get(side, adjacents[2]),
                MovablePosition.Get(side, adjacents[3]),
                MovablePosition.Get(side, adjacents[0] | adjacents[1]),
                MovablePosition.Get(side, adjacents[1] | adjacents[2]),
                MovablePosition.Get(side, adjacents[2] | adjacents[3]),
                MovablePosition.Get(side, adjacents[3] | adjacents[0]),
            });
        }