static void runFizzBuzz() { Console.WriteLine("Results of using FizzBuzzMapper from 1 to 100:"); List <string> list = NumberDecorator.getNumberedList(1, 100, new FizzBuzzMapper()); foreach (String s in list) { Console.WriteLine(s); } }
static void runSquare() { Console.WriteLine("Results of using SquareMapper from 0 to 100:"); var squareMapper = new SquareMapper(); List <string> list = NumberDecorator.getNumberedList(0, 100, squareMapper); foreach (String s in list) { Console.WriteLine(s); } }
public void TestLength() { try { List <string> list = NumberDecorator.getNumberedList(1, 15, new FizzBuzzMapper()); Assert.IsTrue(list.Count == 15); } catch (Exception ex) { Assert.Fail("Unexpected exception: " + ex.Message); } }
public void TestNonNull() { try { List <string> list = NumberDecorator.getNumberedList(1, 15, new FizzBuzzMapper()); Assert.IsNotNull(list); } catch (Exception ex) { Assert.Fail("Unexpected exception: " + ex.Message); } }
public void TestInvalidMapper() { try { List <string> list = NumberDecorator.getNumberedList(1, 100, null); Assert.Fail("Exception should have been thrown for invalid mapper"); } catch (ArgumentException) { //Good. } catch (Exception ex) { //Another kind of exception should not happen Assert.Fail("Unexpected exception: " + ex.Message); } }
public void TestCorrectFizzBuzz() { try { List <string> expected = new List <string>() { "1", "2", "fizz", "4", "buzz", "fizz", "7", "8", "fizz", "buzz", "11", "fizz", "13", "14", "fizzbuzz" }; List <string> list = NumberDecorator.getNumberedList(1, 15, new FizzBuzzMapper()); CollectionAssert.AreEqual(expected, list); } catch (Exception ex) { //Another kind of exception should not happen Assert.Fail("Unexpected exception: " + ex.Message); } }