Example #1
0
        public void FromRandomMovesTest()
        {
            Random random = new Random(7777777);
            int    length = 50;

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => Alg.FromRandomMoves(-1, random));
            Assert.ThrowsException <ArgumentNullException>(() => Alg.FromRandomMoves(0, null));

            Assert.AreEqual(Alg.Empty, Alg.FromRandomMoves(0, random));

            Alg randomAlg = Alg.FromRandomMoves(length, random);

            Assert.AreEqual(length, randomAlg.Length);

            var enumerator = randomAlg.GetEnumerator();

            if (enumerator.MoveNext())
            {
                Move previous2 = enumerator.Current;
                if (enumerator.MoveNext())
                {
                    Move previous1 = enumerator.Current;
                    Assert.AreNotEqual(previous1.Face(), previous2.Face());
                    while (enumerator.MoveNext())
                    {
                        Assert.AreNotEqual(enumerator.Current.Face(), previous1.Face());
                        if (enumerator.Current.Axis() == previous1.Axis())
                        {
                            Assert.AreNotEqual(enumerator.Current.Axis(), previous2.Axis());
                        }
                        previous2 = previous1;
                        previous1 = enumerator.Current;
                    }
                }
            }
        }