コード例 #1
0
ファイル: DietTests.cs プロジェクト: erkofer/NutrientAuto
        public void ShouldRecalculateDietTotalMacrosOnRemoveMeal()
        {
            Diet diet = GetNewDiet();
            Meal meal = diet.AddMeal("Breakfast", "A faster breakfast", new Time(9, 0, 0));
            Food food = new Food("Peito de Frango", "Peito de Frango cozido", Guid.NewGuid(), new MacronutrientTable(20, 48, 21), MicronutrientTable.Default(), new FoodUnit(UnitType.Grams, 1));

            meal.AddMealFood(new MealFood(food, 1));

            diet.RecalculateDietTotalMacros();

            Assert.AreEqual(20, diet.TotalMacronutrients.Carbohydrate);
            Assert.AreEqual(48, diet.TotalMacronutrients.Protein);
            Assert.AreEqual(21, diet.TotalMacronutrients.Fat);

            diet.RemoveMeal(meal);

            Assert.AreEqual(0, diet.TotalMacronutrients.Carbohydrate);
            Assert.AreEqual(0, diet.TotalMacronutrients.Protein);
            Assert.AreEqual(0, diet.TotalMacronutrients.Fat);
        }
コード例 #2
0
ファイル: DietTests.cs プロジェクト: erkofer/NutrientAuto
        public void ShouldRecalculateDietTotalMacros()
        {
            Diet     diet     = GetNewDiet();
            Meal     meal     = diet.AddMeal("Breakfast", "A faster breakfast", new Time(9, 0, 0));
            FoodUnit foodUnit = new FoodUnit(UnitType.Grams, 1);
            Food     food     = new Food("Peito de Frango", "Peito de Frango cozido", Guid.NewGuid(), new MacronutrientTable(0, 24, 2), MicronutrientTable.Default(), foodUnit);
            Food     foodTwo  = new Food("Brócolis", "Brócolis Verde", Guid.NewGuid(), new MacronutrientTable(6, 2, 0), MicronutrientTable.Default(), foodUnit);

            meal.AddMealFood(new MealFood(food, 1));
            meal.AddMealFood(new MealFood(foodTwo, 1));

            diet.RecalculateDietTotalMacros();

            Assert.AreEqual(6, diet.TotalMacronutrients.Carbohydrate);
            Assert.AreEqual(26, diet.TotalMacronutrients.Protein);
            Assert.AreEqual(2, diet.TotalMacronutrients.Fat);
        }
コード例 #3
0
ファイル: MealTests.cs プロジェクト: erkofer/NutrientAuto
        public void ShouldRecalculateMealMacros()
        {
            Meal     meal     = GetMeal();
            FoodUnit foodUnit = new FoodUnit(UnitType.Grams, 1);

            Food food    = new Food("Peito de Frango", "Peito de Frango cozido", Guid.NewGuid(), new MacronutrientTable(0, 24, 2), MicronutrientTable.Default(), foodUnit);
            Food foodTwo = new Food("Brócolis", "Brócolis Verde", Guid.NewGuid(), new MacronutrientTable(6, 2, 0), MicronutrientTable.Default(), foodUnit);

            meal.AddMealFood(new MealFood(food, 1));
            meal.AddMealFood(new MealFood(foodTwo, 1));

            Assert.AreEqual(6, meal.MealMacronutrients.Carbohydrate);
            Assert.AreEqual(26, meal.MealMacronutrients.Protein);
            Assert.AreEqual(2, meal.MealMacronutrients.Fat);
        }
コード例 #4
0
ファイル: MealTests.cs プロジェクト: erkofer/NutrientAuto
        public void ShouldFailToRemoveMealFoodFromMealTwice()
        {
            Meal     meal     = GetMeal();
            FoodUnit foodUnit = new FoodUnit(UnitType.Grams, 1);

            Food     food     = new Food("Bacon", "Bacon de testes", Guid.NewGuid(), MacronutrientTable.Default(), MicronutrientTable.Default(), foodUnit);
            MealFood mealFood = new MealFood(food, 0);

            meal.RemoveMealFood(mealFood);
            meal.RemoveMealFood(mealFood);

            Assert.IsFalse(meal.IsValid);
            Assert.AreEqual("A lista de alimentos dessa refeição não contém esse alimento.", meal.GetNotifications().FirstOrDefault().Description);
        }
コード例 #5
0
ファイル: MealTests.cs プロジェクト: erkofer/NutrientAuto
        public void ShouldAddAndRemoveMealFoodFromMeal()
        {
            Meal     meal     = GetMeal();
            FoodUnit foodUnit = new FoodUnit(UnitType.Grams, 1);

            Food     food     = new Food("Bacon", "Bacon de testes", Guid.NewGuid(), MacronutrientTable.Default(), MicronutrientTable.Default(), foodUnit);
            MealFood mealFood = new MealFood(food, 0);

            meal.AddMealFood(mealFood);
            Assert.AreEqual(1, meal.MealFoodCount);

            meal.RemoveMealFood(mealFood);
            Assert.AreEqual(0, meal.MealFoodCount);
        }
コード例 #6
0
ファイル: MealTests.cs プロジェクト: erkofer/NutrientAuto
        public void ShouldFailToAddMealFoodToMealTwice()
        {
            Meal     meal     = GetMeal();
            FoodUnit foodUnit = new FoodUnit(UnitType.Grams, 1);

            Food     food     = new Food("Bacon", "Bacon de testes", Guid.NewGuid(), MacronutrientTable.Default(), MicronutrientTable.Default(), foodUnit);
            MealFood mealFood = new MealFood(food, 1);

            meal.AddMealFood(mealFood);
            meal.AddMealFood(mealFood);

            Assert.IsFalse(meal.IsValid);
        }