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)); }
public DesAlgorithm(string key) { this.keyService = new KeyService(key); this.permutationService = new PermutationService(); this.pBoxService = new PBoxService(); this.GenerateKeys(); }
static void Main() { string[] firstArray; string[] secondArray; PermutationService _permutationService = new PermutationService(); Console.WriteLine("Please enter the first array - separate elements using spaces"); firstArray = Console.ReadLine().Split(" "); CheckArrayLength(firstArray); CheckElementsAreIntegers(firstArray); Console.WriteLine("Please enter the second array - separate elements using spaces"); secondArray = Console.ReadLine().Split(" "); CheckArrayLength(secondArray); CheckElementsAreIntegers(secondArray); if (_permutationService.CompareArrays(firstArray, secondArray)) { Console.WriteLine("YES"); } else { Console.WriteLine("NO"); } Console.Read(); }
public void GenerateNoResultsWithNoErrorsForEmptyInput() { var items = new string[0]; var permutations = PermutationService.GenerateFor(items).ToArray(); permutations.Length.ShouldBe(0); }
public void No_duplicates_in_any_permutation() { var set = new[] { 1, 2, 3, 4, 5 }; var permutations = new PermutationService().GetPermutations(set, 3); var duplicatePermutations = permutations.Where(permutation => permutation.Distinct().Count() != permutation.Count()); Assert.That(duplicatePermutations.Count(), Is.EqualTo(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())); }
public void GeneratesPermutationsForGivenNames() { var items = new[] { "a", "b", "c" }; var permutations = PermutationService.GenerateFor(items).ToArray(); permutations.Length.ShouldBe(6); permutations.ShouldContain(p => p.SequenceEqual(new[] { "a", "b", "c" })); permutations.ShouldContain(p => p.SequenceEqual(new[] { "b", "a", "c" })); permutations.ShouldContain(p => p.SequenceEqual(new[] { "c", "a", "b" })); permutations.ShouldContain(p => p.SequenceEqual(new[] { "a", "c", "b" })); permutations.ShouldContain(p => p.SequenceEqual(new[] { "b", "c", "a" })); permutations.ShouldContain(p => p.SequenceEqual(new[] { "c", "b", "a" })); }
protected override IProNet LoadProNet(string filename) { // load your implementation here var fileService = new FileService(); var networkValidator = new NetworkValidator(); var networkService = new NetworkRepository(fileService, filename, networkValidator); var rankService = new RankService(networkService); var skillsService = new SkillsService(networkService); var separationService = new SeparationService(networkService); var recommendationService = new RecommendationService(networkService); var teamStrengthService = new TeamStrengthService(separationService, skillsService, rankService); var permutationService = new PermutationService(); var strongestTeamService = new StrongestTeamService(networkService, teamStrengthService, permutationService); return(new ProNet(rankService, skillsService, separationService, recommendationService, teamStrengthService, strongestTeamService)); }
public void TestSetup() { _permutationService = new PermutationService(); }