Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public void MustSolveCrossBeforePlacingFtl()
        {
            var nonSolvedCrossCube = new Cube().Apply(Turn.Parse("R"));
            var slot = new FtlSlot(Side.Front, Side.Right);

            Assert.Throws <System.InvalidOperationException>(() => Solver.PlaceSingleFtlPairFromTop(slot, nonSolvedCrossCube));
        }
Ejemplo n.º 3
0
 public void ToStringParseRoundTrip_AllPossibleTurns()
 {
     foreach (var turn in Turn.BuildAllTurns())
     {
         string text = turn.ToString();
         var    copy = Turn.Parse(text);
         Assert.Equal(turn, copy);
     }
 }
Ejemplo n.º 4
0
        static public TurnSequence Parse(string s)
        {
            var items = new List <Turn>();

            for (int i = 0; i < s.Length; ++i)
            {
                var turn = Turn.Parse(s, i);
                items.Add(turn);
                if (turn.Direction != Rotation.Clockwise)
                {
                    ++i;
                }
            }
            return(new TurnSequence(items.ToArray()));
        }