public void Rotate_UpperClockwise()
        {
            var brd = new T { Id = "brd" };
            var bld = new T { Id = "bld" };
            var bru = new T { Id = "bru" };
            var blu = new T { Id = "blu" };
            var frd = new T { Id = "frd" };
            var fld = new T { Id = "fld" };
            var fru = new T { Id = "fru" };
            var flu = new T { Id = "flu" };

            var frontFace = new[,] { { flu, fru }, { fld, frd } };
            var backFace = new[,] { { bru, blu }, { brd, bld } };
            var faceTop = new[,] { { flu, fru }, { blu, bru } };
            var faceBottom = new[,] { { bld, brd }, { fld, frd } };
            var faceLeft = new[,] { { blu, flu }, { bld, fld } };
            var faceRight = new[,] { { fru, bru }, { frd, brd } };
            var config = new CubeConfiguration<T>(faceTop, faceBottom, faceLeft, faceRight, frontFace, backFace);

            config.Rotate(Rotations.UpperClockwise);

            CollectionAssert.AreEqual(new[,] { { fru, bru }, { fld, frd } }, config.Faces[FaceType.Front].Items);
            CollectionAssert.AreEqual(new[,] { { flu, fru }, { bld, fld } }, config.Faces[FaceType.Left].Items);
            CollectionAssert.AreEqual(new[,] { { blu, flu }, { brd, bld } }, config.Faces[FaceType.Back].Items);
            CollectionAssert.AreEqual(new[,] { { bru, blu }, { frd, brd } }, config.Faces[FaceType.Right].Items);
        }
        public void ThreeDimensional()
        {
            var ldb = new Object();
            var cdb = new Object();
            var rdb = new Object();
            var lcb = new Object();
            var ccb = new Object();
            var rcb = new Object();
            var lub = new Object();
            var cub = new Object();
            var rub = new Object();

            var ldc = new Object();
            var cdc = new Object();
            var rdc = new Object();
            var lcc = new Object();
            var rcc = new Object();
            var luc = new Object();
            var cuc = new Object();
            var ruc = new Object();

            var ldf = new Object();
            var cdf = new Object();
            var rdf = new Object();
            var lcf = new Object();
            var ccf = new Object();
            var rcf = new Object();
            var luf = new Object();
            var cuf = new Object();
            var ruf = new Object();

            var frontFace = new[,] { { luf, cuf, ruf }, { lcf, ccf, rcf }, { ldf, cdf, rdf } };
            var rightFace = new[,] { { ruf, ruc, rub }, { rcf, rcc, rcb }, { rdf, rdc, rdb } };
            var backFace = new[,] { { rub, cub, lub }, { rcb, ccb, lcb }, { rdb, cdb, ldb } };
            var leftFace = new[,] { { lub, luc, luf }, { lcb, lcc, lcf }, { ldb, ldc, ldf } };
            var topFace = new[,] { { lub, cub, rub }, { luc, cuc, ruc }, { luf, cuf, ruf } };
            var downFace = new[,] { { ldf, cdf, rdf }, { ldc, cdc, rdc }, { ldb, cdb, rdb } };

            var config = new CubeConfiguration<object>(topFace, downFace, leftFace, rightFace, frontFace, backFace);
            config.Rotate(Rotations.RightClockwise);

            CollectionAssert.AreEqual(new[,] { { rdf, rcf, ruf }, { rdc, rcc, ruc }, { rdb, rcb, rub } }, config.Faces[FaceType.Right].Items);
            CollectionAssert.AreEqual(new[,] { { lub, cub, ruf }, { luc, cuc, rcf }, { luf, cuf, rdf } }, config.Faces[FaceType.Upper].Items);
        }
Пример #3
0
        public static void ApplyRotations(IEnumerable<IRotation> rotations, CubeConfiguration<FaceColour> configuration)
        {
            foreach (var rotation in rotations)
            {
                var cubeRotation = rotation as CubeRotation;
                var faceRotation = rotation as FaceRotation;

                if (cubeRotation != null)
                {
                    configuration.RotateCube(cubeRotation).Wait();
                }
                if (faceRotation != null)
                {
                    configuration.Rotate(faceRotation).Wait();
                }
            }
        }