예제 #1
0
        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");
        }
예제 #2
0
        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);
        }
예제 #3
0
        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();
        }
예제 #4
0
 public DivisibleEnumerator(DivisibleList list)
 {
     _list = list;
     _current = list.Start;
     _evaluator = new DivisibleEvaluator(_list.Rules);
 }
예제 #5
0
        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");
        }
예제 #6
0
 public void TestCheckArguments()
 {
     var list = new DivisibleList(-5, -10);
 }
예제 #7
0
        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));
        }