Exemple #1
0
        public void TestBasicInput(string input, int minimumSolutions, int minClosenessOfBestSolution)
        {
            List <NumbersSolution> solutions = _numbersController.SolveNumbers(input).ToList();

            Assert.NotNull(solutions);

            Assert.True(solutions.Count() >= minimumSolutions);

            if (minimumSolutions > 0)
            {
                Assert.True(minClosenessOfBestSolution >= solutions.First().Closeness);
            }

            if (minimumSolutions > 0)
            {
                int numberOfInputs = input.Split(",").Count() - 1;
                CollectionsHelper collectionsHelper = new CollectionsHelper();
                int factorial       = collectionsHelper.Factorial(numberOfInputs);
                var justTheStrings  = solutions.Select((s) => s.Solution).ToList();
                int uniqueSolutions = justTheStrings.Distinct().Count();
                _output.WriteLine("Statistics: # of inputs {0}, max results {1}, unique results {2}, actual results {3}", numberOfInputs, factorial, uniqueSolutions, solutions.Count());
            }
        }
Exemple #2
0
        public void TestFactorial(int input, int output)
        {
            int actualOutput = Helper.Factorial(input);

            Assert.Equal(output, actualOutput);
        }