Esempio n. 1
0
        public void All_permutations_generated_when_all_elements_are_the_same()
        {
            // Arrange
            var sut = new PermutationIterator <int>(new[] { 5, 5, 5 }, true);

            // Act
            var result = sut.ToList();

            // Assert
            result.Should()
            .HaveCount(6).And
            .AllBeEquivalentTo(new[] { 5, 5, 5 });
        }
Esempio n. 2
0
        public void All_permutations_generated()
        {
            // Arrange
            var sut = new PermutationIterator <int>(new[] { 1, 2, 3 }, true);

            var expected = new List <int[]>
            {
                new[] { 1, 2, 3 },
                new[] { 1, 3, 2 },
                new[] { 2, 1, 3 },
                new[] { 2, 3, 1 },
                new[] { 3, 1, 2 },
                new[] { 3, 2, 1 }
            };

            // Act
            var result = sut.ToList();

            // Assert
            // This FluentAssertion is based on:
            // https://stackoverflow.com/questions/68527627/fluent-assertions-equivalency-of-two-lists-of-arrays-with-arrays-needing-stric
            result.Should().BeEquivalentTo(expected, options => options
                                           .WithStrictOrderingFor(info => info.RuntimeType == typeof(int[])));
        }