public void WhenTheDishInputIsInvalidThenAnExceptionIsThrown(string input)
        {
            string[] dishes = input.Split(new char[] {','});

            IInputParser inputParser = new InputParser();
            inputParser.ValidateDishes(dishes);
        }
        public void WhenTheTimeOfDayIsValidThenNoExceptionsAreThrown()
        {
            IInputParser inputParser = new InputParser();

            Assert.AreEqual("morning", inputParser.ValidateTimeOfDay("morning"));
            Assert.AreEqual("morning", inputParser.ValidateTimeOfDay(" morning  "));
            Assert.AreEqual("night", inputParser.ValidateTimeOfDay("night"));
            Assert.AreEqual("night", inputParser.ValidateTimeOfDay("  night  "));
        }
        public void WhenTheDishesAreValidThenAListIsReturned()
        {
            string[] inputDishes = {"1", "2", "3", "4"};

            IInputParser inputParser = new InputParser();
            IList<int> dishes = inputParser.ValidateDishes(inputDishes);

            Assert.AreEqual(4, dishes.Count);
        }
        public void GivenCorrectInputParametersThenValidResultsAreReturned()
        {
            string input = "morning, 1, 2, 3";

            IInputParser inputParser = new InputParser();
            IParameters parameters = inputParser.Parse(input);

            Assert.AreEqual(Constants.Morning, parameters.TimeOfDay);
            Assert.AreEqual(3, parameters.Dishes.Count);
        }
Exemple #5
0
        public static void ProcessMeal(string input)
        {
            IList<string> output = new List<string>();

            try
            {
                IInputParser inputParser = new InputParser();
                IParameters parameters = inputParser.Parse(input);

                IDictionary<int, string> mealMap = MealMapFactory.Create(parameters.TimeOfDay);
                IMealFactory mealFactory = MealFactory.Create(parameters.TimeOfDay);
                IRuleSet rule = mealFactory.GetRules(mealMap, parameters.Dishes, output);
                rule.Execute();
            }
            catch (Exception e)
            {
                if (output.Count == 0) output.Add(e.Message);
                Debug.WriteLine(string.Format("Exception: {0}", e.Message));
            }
            finally
            {
                Print(output);
            }
        }
 public void WhenTimeOfDayIsNotValidThenAnExceptionIsThrown(string input)
 {
     IInputParser inputParser = new InputParser();
     inputParser.ValidateTimeOfDay(input);
 }
        public void WhenNoDishesExistThenAnExceptionIsThrown()
        {
            IInputParser inputParser = new InputParser();

            inputParser.ValidateDishes(new string[] { });
        }
 public void GivenInvalidInputThenAnExceptionIsThrown(string input)
 {
     IInputParser inputParser = new InputParser();
     inputParser.Parse(input);
 }