예제 #1
0
        public void ProcessNumber_Should_Evaluate_Custom_Rule()
        {
            var fizzBuzz = new RulesEngine();
            const string textForMatches = "FOUR!";

            var result = fizzBuzz.ProcessNumber(4, ((x) => x == 4), textForMatches);
            Assert.AreEqual("even " + textForMatches, result);
        }
예제 #2
0
        public void ProcessNumber_Should_Bypass_Default_Rules_If_Apply_Default_Rules_IsFalse()
        {
            var fizzBuzz = new RulesEngine();
            const string textForMatches = "FOUR!";

            var result = fizzBuzz.ProcessNumber(4, ((x) => x == 4), textForMatches, false);
            Assert.AreEqual(textForMatches, result);
        }
예제 #3
0
        public void ProcessNumber_Should_Evaluate_Multiple_Custom_Rules()
        {
            var fizzBuzz = new RulesEngine();
            const string textForMatches4 = "FOUR!";
            const string textForGreaterThan3 = "GREATER_THAN_THREE";

            var rules = new Dictionary<NumberRule, string>()
            {
                {(x) => x == 4, textForMatches4},
                {(x) => x > 3, textForGreaterThan3}
            };

            var result = fizzBuzz.ProcessNumber(4, rules);
            Assert.AreEqual("even " + textForMatches4 + " " + textForGreaterThan3, result);
        }
예제 #4
0
 public void ProcessNumber_Should_Return_Odd_For_1()
 {
     var fizzBuzz = new RulesEngine();
     var result = fizzBuzz.ProcessNumber(1);
     Assert.AreEqual("odd", result);
 }
예제 #5
0
 public void ProcessNumber_Should_Return_Even_For_4()
 {
     var fizzBuzz = new RulesEngine();
     var result = fizzBuzz.ProcessNumber(4);
     Assert.AreEqual("even", result);
 }