Esempio n. 1
0
        public void Shuffle_YieldsAllElementsOfOriginalSequence()
        {
            var sequence = Fixture.CreateMany <int>().ToList();

            SetUpRandomBehavior(sequence.Count);

            var shuffledSequence = _shuffler.Shuffle(sequence);

            Assert.That(shuffledSequence, Is.EquivalentTo(sequence));
        }
Esempio n. 2
0
        public static void ArrayShuffled_NewArrayHasSameSize(
            [Random(0, 1000, 100, Distinct = true)]
            int n)
        {
            // Arrange
            var shuffler = new FisherYatesShuffler <int>();

            var(correctArray, testArray) = RandomHelper.GetArrays(n);

            // Act
            shuffler.Shuffle(testArray);

            // Assert
            testArray.Length.Should().Be(correctArray.Length);
        }
Esempio n. 3
0
        public static void ArrayShuffled_NewArrayHasSameValues(
            [Random(0, 1000, 100, Distinct = true)]
            int n)
        {
            // Arrange
            var shuffler = new FisherYatesShuffler <int>();

            var(correctArray, testArray) = RandomHelper.GetArrays(n);

            // Act
            shuffler.Shuffle(testArray);
            Array.Sort(testArray);
            Array.Sort(correctArray);

            // Assert
            testArray.Should().BeEquivalentTo(correctArray);
        }