Example #1
0
 public void Even_shouldPrintFirstNumber()
 {
     EvenNumbers even = new EvenNumbers();
     int expected = 2;
     int actual = even.GetFirst();
     Assert.AreEqual(expected, actual);
 }
Example #2
0
 public void Even_shouldPrintNextNumber()
 {
     EvenNumbers even = new EvenNumbers();
     int input = 2;
     int expected = 4;
     int actual = even.GetNext(input);
     Assert.AreEqual(expected, actual);
 }
Example #3
0
 public void Even_shouldPrintAVariableSequenceOfNumbers()
 {
     EvenNumbers even = new EvenNumbers();
     int input = 8;
     int[] expected = new int[] { 2,4,6,8,10,12,14,16 };
     int[] actual = even.GetSequence(input);
     CollectionAssert.AreEqual(expected, actual);
 }
Example #4
0
 public void Even_printSequenceOfNumbers()
 {
     EvenNumbers even = new EvenNumbers();
     int length = 7;
     string expected = "2 4 6 8 10 12 14";
     string actual = even.ToString(even.GetSequence(length));
     Assert.AreEqual(expected, actual);
 }
Example #5
0
 static void Main(string[] args)
 {
     string prompt = "1.) Natural Numbers\n2.) Even Numbers\n3.) Odd Numbers\n4.) Prime Numbers\n5.) Fibonacci Numbers\n";
     Console.Write("What do you want me to do? \n");
     Console.Write(prompt);
     string response = Console.ReadLine();
     if (response == "1")
     {   //Natty
         Console.WriteLine("How many?");
         //Console.WriteLine(prompt);
         int length;
         string response_length = Console.ReadLine();
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
           NaturalNumbers nats = new NaturalNumbers();
           Console.WriteLine(nats.ToString(nats.GetSequence(length)));
         }
     }
     else if (response == "2")
     {   //Even
         Console.WriteLine("How many?");
         //Console.WriteLine(prompt);
         int length;
         string response_length = Console.ReadLine();
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             EvenNumbers Even = new EvenNumbers();
             Console.WriteLine(Even.ToString(Even.GetSequence(length)));
         }
     }
     else if (response == "3")
     {   //Odd
         Console.WriteLine("How many?");
         //Console.WriteLine(prompt);
         int length;
         string response_length = Console.ReadLine();
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             OddNumbers Odd = new OddNumbers();
             Console.WriteLine(Odd.ToString(Odd.GetSequence(length)));
         }
     }
     else if (response == "4")
     {   //Prime
         Console.WriteLine("How many?");
         //Console.WriteLine(prompt);
         int length;
         string response_length = Console.ReadLine();
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             PrimeNumbers primes = new PrimeNumbers();
             Console.WriteLine(primes.ToString(primes.GetSequence(length)));
         }
     }
     else if (response == "5")
     {   //Fib
         Console.WriteLine("How many?");
         //Console.WriteLine(prompt);
         int length;
         string response_length = Console.ReadLine();
         bool parsed = int.TryParse(response_length, out length);
         if (parsed)
         {
             FibNumbers fibs = new FibNumbers();
             Console.WriteLine(fibs.ToString(fibs.GetSequence(length)));
         }
      }
      else
      {
         Console.WriteLine("Whoops! Try a number next time.");
      }
     Console.WriteLine("Press any key to exit");
     Console.ReadKey();
 }
Example #6
0
 public void Even_EnsureICanCreateClassInstance()
 {
     EvenNumbers even = new EvenNumbers();
     Assert.IsNotNull(even);
 }