public void TestFizzBuzzDefault() { var results = new Dictionary<int, string>(); var list = new DivisibleList(1, 100); foreach (DivisibleResult item in list) { results.Add(item.Value, item.Phrase); } Assert.AreEqual(results[7], "7"); Assert.AreEqual(results[5], "Buzz"); }
public void TestLargeRange() { int count = 0; bool passed10000 = false; var list = new DivisibleList(1, Int32.MaxValue); foreach (DivisibleResult item in list) { count++; if (count > 10000) { passed10000 = true; break; } } Assert.IsTrue(passed10000); }
static void Main(string[] args) { Console.WriteLine("FizzBuzzEngine"); Console.WriteLine(""); var engine = new FizzBuzzEngine(1, 100); foreach (var item in engine.GenerateResults()) { Console.WriteLine(item.Value); } Console.WriteLine(""); Console.WriteLine("DivisibleList"); Console.WriteLine(""); DivisibleList list = new DivisibleList(1, 100); foreach (DivisibleResult item in list) { Console.WriteLine(item.Phrase); } Console.ReadKey(); }
public DivisibleEnumerator(DivisibleList list) { _list = list; _current = list.Start; _evaluator = new DivisibleEvaluator(_list.Rules); }
public void TestList() { var results = new Dictionary<int, string>(); var list = new DivisibleList(1, 100, _testRules); foreach (DivisibleResult item in list) { results.Add(item.Value, item.Phrase); } Assert.IsTrue(results[7] == "Cow"); }
public void TestCheckArguments() { var list = new DivisibleList(-5, -10); }
public void TestPrimes() { var primes = new List<int>(); var list = new DivisibleList(1, 100, _testRulesPrimes); foreach (DivisibleResult item in list) { if (_testRulesPrimes.Any(r => r.Divisor == item.Value) || item.IsDivisible == false) { primes.Add(item.Value); } } Assert.IsTrue(primes.Contains(2)); Assert.IsTrue(primes.Contains(31)); Assert.IsFalse(primes.Contains(10)); }