static void Main(string[] args) { Console.WindowWidth = 120; var fizzBuzz = new FizzBuzz(); Console.WriteLine("Enter a number/word pair. Separate the number and word by a comma. Then press enter. i.e. 3,Fizz"); Console.WriteLine("When you are done entering values, simply press enter without entering any value."); while (true) { string value = Console.ReadLine(); if (string.IsNullOrEmpty(value)) { break; } var pair = ParseValue(value); if (pair.HasValue) { fizzBuzz.Pairs.Add(pair.Value.Key, pair.Value.Value); } } foreach (string value in fizzBuzz.Execute(1, 100)) { Console.WriteLine(value); } Console.WriteLine("Press any key to exit"); Console.ReadKey(); }
public void FizzBuzz_Returns_Fizz_When_Value_Is_Divisible_By_3() { var fizzBuzz = new FizzBuzz(); fizzBuzz.AddPair(3, "Fizz"); Assert.AreEqual("Fizz", fizzBuzz.Execute(3, 3).First()); }
public void Exception_Thrown_When_Upper_Is_Less_Than_Lower() { var fizzBuzz = new FizzBuzz(); fizzBuzz.AddPair(3, "Fizz"); Assert.AreEqual("Buzz", fizzBuzz.Execute(5, 4).First()); }
public void Can_Add_NumberWord_Pair_To_FizzBuzz() { var fizzBuzz = new FizzBuzz(); fizzBuzz.AddPair(3, "Fizz"); Assert.AreEqual(1, fizzBuzz.Pairs.Count); }
static void Main(string[] args) { FizzBuzz fb = new FizzBuzz(); List<Divisiblity> divs = new List<Divisiblity>(); Divisiblity div = new Divisiblity(3, "fizz"); divs.Add(div); div = new Divisiblity(5, "buzz"); divs.Add(div); div = new Divisiblity(8, "pop"); divs.Add(div); fb.DoIt(100, divs, Console.Out); /* another caller, perhaps from a non-Console application could call DoIt as follows to get results to a file using (var sw = new StreamWriter("file.txt")) { fb.DoIt(40000, divs, sw); } */ // leave the Console up while the caller looks at the results Console.WriteLine("... done. Press a key when you are done reviewing results."); Console.ReadLine(); }
public void FizzBuzz_Returns_Number_When_Value_Is_Not_Divisible_By_3() { var fizzBuzz = new FizzBuzz(); fizzBuzz.AddPair(3, "Fizz"); fizzBuzz.AddPair(5, "Buzz"); Assert.AreEqual("1", fizzBuzz.Execute(1, 1).First()); Assert.AreEqual("13", fizzBuzz.Execute(13, 13).First()); }