public void CreateCombinations_100FeaturesNoConstraints_Generate10000UniqueCombinations() { // Arrange var numberOfFeatures = 100; var features = new List <Feature>(); for (int i = 0; i < numberOfFeatures; i++) { features.Add(new Feature($"feature #{i}", 1, 5)); } var constraints = new List <IConstraint>(); var candidate = new CreateCombinationsService( new ConstraintValidatorFactory(), new RandomCombinationGenerator(new PseudoRandomizer(12567))); // Act var maxNumberOfAttempts = 10000; var combinationList = new List <ICombination>(); candidate.CreateCombinations( features, constraints, c => combinationList.Add(c), () => true, maxNumberOfAttempts); // Assert Assert.AreEqual(maxNumberOfAttempts, combinationList.Count); Assert.AreEqual(combinationList.Count, combinationList.Distinct().Count()); }
private static IEnumerable <ICombination> CreateCombinations( IEnumerable <Feature> features, int numberOfCombinations) { ArgumentChecks.AssertNotNull(features, nameof(features)); var createCombinationsService = new CreateCombinationsService( new ConstraintValidatorFactory(), new RandomCombinationGenerator(new PseudoRandomizer(1257))); var combinationList = new List <ICombination>(); createCombinationsService.CreateCombinations( features, new IConstraint[0], c => combinationList.Add(c), () => combinationList.Count < numberOfCombinations, numberOfCombinations * 2); return(combinationList); }