コード例 #1
0
        public void TestShuffle()
        {
            var       rnd        = new Random(10);
            const int count      = 100;
            var       ariShuffle = new int[count];

            for (var i = 0; i < count; i++)
            {
                ariShuffle[i] = i;
            }
            Assert.AreEqual(0, ariShuffle[0]);
            Assert.AreEqual(99, ariShuffle[99]);
            Graph.Shuffle(ariShuffle, rnd);
            Assert.AreNotEqual(0, ariShuffle[0]);
            Assert.AreNotEqual(99, ariShuffle[99]);

            var iTotal = 0;

            for (var i = 0; i < count; i++)
            {
                iTotal += ariShuffle[i];
            }
            Assert.AreEqual(count * (count - 1) / 2, iTotal);
        }