Пример #1
0
 private static void PrintData(IEnumerable <RecipeCost> recipeCosts)
 {
     foreach (var o in recipeCosts)
     {
         Console.WriteLine($"Recipe {o.Recipe.RecipeName} | Cost: ${RecipeCostCalculator.CalculateTotalCost(o)}");
     }
 }
Пример #2
0
        public Recipe GetRecipeWithIngredients(int id = 0)
        {
            var recipe            = (Recipe) new RecipeViewModel().FetchData(id);
            var recipeIngredients = (IEnumerable <RecipeIngredients>) new RecipeIngredientsViewModel().FetchData(id);

            recipe.RecipeIngredients = Build(recipeIngredients, recipe);
            recipe.Cost = RecipeCostCalculator.CalculateRecipe(recipe.RecipeIngredients);

            return(recipe);
        }
Пример #3
0
        public void Should_Calulate_Cost_Of_Recipe()
        {
            var rc = new RecipeCost {
                Recipe = new Recipe {
                    Id = 1, RecipeName = "Oatmeal with Honey", Servings = 1
                }, RecipeComponents = recipeComponents
            };

            Assert.AreEqual(.68m, RecipeCostCalculator.CalculateTotalCost(rc));
        }
 public decimal CalculateCostOfSingleIngredientInARecipe(RecipeCostComponent recipeCostComponent)
 {
     return(RecipeCostCalculator.CostOfIngredient(recipeCostComponent));
 }
        public decimal SumOfAllIngredientsForRecipe(int recipeId)
        {
            var data = (IEnumerable <RecipeCostComponent>)FetchData(recipeId);

            return(RecipeCostCalculator.CalculateCostOfIngredients(data));
        }
Пример #6
0
 public void Should_Calculate_Cost_Of_Ingredients()
 {
     Assert.AreEqual(.68m, RecipeCostCalculator.CalculateCostOfIngredients(recipeComponents));
 }