Esempio n. 1
0
 public void FibShouldPrintFirstNumber()
 {
     Fibonacci fib = new Fibonacci();
     int expected = 0;
     int actual = fib.GetFirst();
     Assert.AreEqual(expected, actual);
 }
Esempio n. 2
0
 public void FibShouldPrintNextNumber()
 {
     Fibonacci fib = new Fibonacci();
     int input = 0;
     int expected = 1;
     int actual = fib.GetNext(input);
     Assert.AreEqual(expected, actual);
 }
Esempio n. 3
0
 public void FibShouldPrintAVariableSequenceOfNumbers()
 {
     Fibonacci fib = new Fibonacci();
     int length = 5;
     int[] expected = new int[] { 0, 1, 1, 2, 3 };
     int[] actual = fib.GetSequence(length);
     CollectionAssert.AreEqual(expected, actual);
 }
Esempio n. 4
0
 public void FibPrintSequenceOfNumbers()
 {
     Fibonacci fib = new Fibonacci();
     int length = 7;
     string expected = "0 1 1 2 3 5 8";
     string actual = fib.ToString(fib.GetSequence(length));
     Assert.AreEqual(expected, actual);
 }
Esempio n. 5
0
        static void Main(string[] args)
        {
            string prompt = "> ";
            Console.WriteLine("What do you want me to do?");
            Console.Write(prompt);
            string response = Console.ReadLine();
            if (response.ToLower().Contains("numbers"))
            {
                Console.WriteLine("How many?");
                Console.Write(prompt);
                int length;
                string response_length = Console.ReadLine();
                bool parsed = int.TryParse(response_length, out length);
                if (parsed && Convert.ToInt32(response_length) < 1000)
                {
                    if (response.ToLower().Equals("natural numbers"))
                    {
                        NaturalNumbers nats = new NaturalNumbers();
                        Console.WriteLine(nats.ToString(nats.GetSequence(length)));
                    }
                    else if (response.ToLower().Equals("even numbers"))
                    {
                        EvenNumbers even = new EvenNumbers();
                        Console.WriteLine(even.ToString(even.GetSequence(length)));
                    }
                    else if (response.ToLower().Equals("odd numbers"))
                    {
                        OddNumbers odd = new OddNumbers();
                        Console.WriteLine(odd.ToString(odd.GetSequence(length)));
                    }
                    else if (response.ToLower().Equals("fibonacci numbers"))
                    {
                        Fibonacci fib = new Fibonacci();
                        Console.WriteLine(fib.ToString(fib.GetSequence(length)));
                    }
                    else if (response.ToLower().Equals("prime numbers"))
                    {
                        PrimeNumbers prime = new PrimeNumbers();
                        Console.WriteLine(prime.ToString(prime.GetSequence(length)));
                    }
                    else
                    {
                        Console.WriteLine("Whoops!");
                    }

                }
                else {
                    Console.WriteLine("Whoops!");
                }
            }
            else {
                Console.WriteLine("Nope! Do better next time.");
            }
            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
Esempio n. 6
0
 public void FibEnsureICanCreateClassInstance()
 {
     Fibonacci fib = new Fibonacci();
     Assert.IsNotNull(fib);
 }