Beispiel #1
0
        public void Correct_number_of_results(int size, int expected)
        {
            var set          = new[] { 1, 2, 3, 4, 5 };
            var permutations = new PermutationService().GetPermutations(set, size);

            Assert.That(permutations.Count(), Is.EqualTo(expected));
        }
Beispiel #2
0
        public void No_permutations_have_the_same_exact_items()
        {
            var set          = new[] { 1, 2, 3, 4, 5 };
            var permutations = new PermutationService().GetPermutations(set, 3);
            var permutationsWithSameItems = permutations
                                            .Select(permutation => permutation.OrderBy(x => x))
                                            .Distinct();

            Assert.That(permutations.Count(), Is.EqualTo(permutationsWithSameItems.Count()));
        }