Example #1
0
        private static List <int> GetFibNums(int n)
        {
            var nums = new List <int>();

            for (var i = 0; i < n; i++)
            {
                nums.Add(FibonacciGenerator.FibonacciNumber(i));
            }
            return(nums);
        }
Example #2
0
        public static FibonacciGenerator BuildFibonacciGenerator(int n, string dictType)
        {
            var generator = new FibonacciGenerator();

            if (dictType.Equals("SortedDictionary"))
            {
                generator._cache = new SortedDictionary <int, int>();
            }
            else
            {
                generator._cache = new Dictionary <int, int>();
            }

            generator.BuildFibNums(n);

            return(generator);
        }
Example #3
0
        public void FibonacciDictGeneratorTest()
        {
            var gen = FibonacciGenerator.BuildFibonacciGenerator(21, "Dictionary");

            CollectionAssert.AreEqual(First21Fibs, gen.Nums);
        }