Exemplo n.º 1
0
        public void GoalChange()
        {
            ClientInformation oldInfo = new ClientInformation()
            {
                ActivityRate      = 1.55,
                AverageWeightInKg = 83.55,
                BodyFatPercentage = .1288,
                Goal = new Goal()
                {
                    Intensity = GoalIntensityType.Maintain,
                    Type      = GoalType.Maintain
                }
            };

            ClientInformation newInfo = new ClientInformation()
            {
                ActivityRate      = 1.55,
                AverageWeightInKg = 83.25,
                BodyFatPercentage = .1288,
                Goal = new Goal()
                {
                    Intensity = GoalIntensityType.Moderate,
                    Type      = GoalType.Gain
                }
            };

            MacroCalculation currentMacros = NutritionBoi.Logic.MTL.Calculate(oldInfo);

            MacroCalculation newMacros     = NutritionBoi.Logic.MTL.Calculate(newInfo, currentMacros.CaloricMaintainanceAdjustment);
            MacroCalculation updatedMacros = NutritionBoi.Logic.MTL.UpdateMacros(currentMacros, oldInfo, newInfo);

            // We lost more than our anticpated goal, which means it should increase our calories
            Assert.AreEqual(updatedMacros.Calories, newMacros.Calories);
        }
Exemplo n.º 2
0
        public void UpdateGainLightTooMuch()
        {
            ClientInformation oldInfo = new ClientInformation()
            {
                ActivityRate      = 1.55,
                AverageWeightInKg = 83.55,
                BodyFatPercentage = .1288,
                Goal = new Goal()
                {
                    Intensity = GoalIntensityType.Light,
                    Type      = GoalType.Gain
                }
            };

            ClientInformation newInfo = new ClientInformation()
            {
                ActivityRate      = 1.55,
                AverageWeightInKg = 84.40,
                BodyFatPercentage = .1290,
                Goal = new Goal()
                {
                    Intensity = GoalIntensityType.Light,
                    Type      = GoalType.Lose
                }
            };

            MacroCalculation currentMacros = NutritionBoi.Logic.MTL.Calculate(oldInfo);
            MacroCalculation newMacros     = NutritionBoi.Logic.MTL.UpdateMacros(currentMacros, oldInfo, newInfo);

            // We lost more than our anticpated goal, which means it should increase our calories
            Assert.IsTrue(currentMacros.Calories > newMacros.Calories);
        }
Exemplo n.º 3
0
        private static MacroCalculation CustomizeMacroPercentagesForGoal(ClientInformation clientInfo, double adjustedTotalDailyEnergyExpenditure)
        {
            MacroCalculation calculation = null;

            if (clientInfo.Goal.Type == GoalType.Maintain)
            {
                return(CustomizeMacroPercentagesForMaintenance(clientInfo, adjustedTotalDailyEnergyExpenditure));
            }

            if (clientInfo.Goal.Type == GoalType.Lose)
            {
                switch (clientInfo.Goal.Intensity)
                {
                case GoalIntensityType.Light:
                    calculation = CustomizeMacroPercentagesForLossLight(clientInfo, adjustedTotalDailyEnergyExpenditure);
                    break;

                case GoalIntensityType.Moderate:
                    calculation = CustomizeMacroPercentagesForLossModerate(clientInfo, adjustedTotalDailyEnergyExpenditure);
                    break;

                case GoalIntensityType.Intense:
                    calculation = CustomizeMacroPercentagesForLossIntense(clientInfo, adjustedTotalDailyEnergyExpenditure);
                    break;
                }

                return(calculation);
            }

            if (clientInfo.Goal.Type == GoalType.Gain)
            {
                switch (clientInfo.Goal.Intensity)
                {
                case GoalIntensityType.Light:
                    calculation = CustomizeMacroPercentagesForGainLight(clientInfo, adjustedTotalDailyEnergyExpenditure);
                    break;

                case GoalIntensityType.Moderate:
                    calculation = CustomizeMacroPercentagesForGainModerate(clientInfo, adjustedTotalDailyEnergyExpenditure);
                    break;

                case GoalIntensityType.Intense:
                    calculation = CustomizeMacroPercentagesForGainIntense(clientInfo, adjustedTotalDailyEnergyExpenditure);
                    break;
                }

                return(calculation);
            }

            return(null);
        }
Exemplo n.º 4
0
        public static MacronutrientsModel Parse(MacroCalculation mtlModel)
        {
            MacronutrientsModel model = new MacronutrientsModel();

            model.CaloricMaintainanceAdjustment = mtlModel.CaloricMaintainanceAdjustment;
            model.Carbohydrates = mtlModel.Carbohydrates;
            model.Fats          = mtlModel.Fats;
            model.Proteins      = mtlModel.Proteins;

            model.Calories = mtlModel.CaloricMaintainanceAdjustment + mtlModel.Carbohydrates * 4 + mtlModel.Fats * 9 + mtlModel.Proteins * 4;

            model.CalculatedDate = DateTime.Today;

            return(model);
        }
Exemplo n.º 5
0
        // To be used when we have already given someone their macros.
        public static MacroCalculation UpdateMacros(MacroCalculation currentMacros, ClientInformation oldClientInfo, ClientInformation updatedClientInfo)
        {
            // Goal changed, just update their macro calculation
            if (oldClientInfo.Goal.Type != updatedClientInfo.Goal.Type)
            {
                return(Calculate(updatedClientInfo, currentMacros.CaloricMaintainanceAdjustment));
            }

            double changeAmount = 0;

            switch (updatedClientInfo.Goal.Intensity)
            {
            case GoalIntensityType.Maintain:
                changeAmount = 0;
                break;

            case GoalIntensityType.Light:
                if (updatedClientInfo.Goal.Type == GoalType.Gain)
                {
                    changeAmount = 0.01 / 4;
                }
                else
                {
                    changeAmount = -0.01 / 4;
                }
                break;

            case GoalIntensityType.Moderate:
                if (updatedClientInfo.Goal.Type == GoalType.Gain)
                {
                    changeAmount = 0.02 / 4;
                }
                else
                {
                    changeAmount = -0.02 / 4;
                }
                break;

            case GoalIntensityType.Intense:
                if (updatedClientInfo.Goal.Type == GoalType.Gain)
                {
                    changeAmount = 0.03 / 4;
                }
                else
                {
                    changeAmount = -0.03 / 4;
                }
                break;
            }

            var goalWeightChangeInKG   = oldClientInfo.AverageWeightInKg * changeAmount;
            var realWeightChangeInKG   = updatedClientInfo.AverageWeightInKg - oldClientInfo.AverageWeightInKg;
            var deltaWeightChangeInKG  = goalWeightChangeInKG - realWeightChangeInKG;
            var newCaloricMaintainence = 0.0;

            if (updatedClientInfo.Goal.Type == GoalType.Gain)
            {
                if (deltaWeightChangeInKG > 0.0)
                {
                    // We didn't gain enough
                    newCaloricMaintainence = RecalculateCaloriesBasedOnGoal(deltaWeightChangeInKG);
                }
                if (deltaWeightChangeInKG < 0.0)
                {
                    // We gained too much
                    newCaloricMaintainence = RecalculateCaloriesBasedOnGoal(-1 * deltaWeightChangeInKG);
                }
            }

            if (updatedClientInfo.Goal.Type == GoalType.Lose)
            {
                newCaloricMaintainence = RecalculateCaloriesBasedOnGoal(deltaWeightChangeInKG);
            }

            if (updatedClientInfo.Goal.Type == GoalType.Maintain)
            {
                newCaloricMaintainence = RecalculateCaloriesBasedOnGoal(deltaWeightChangeInKG);
            }

            var updatedCaloricMaintainence = newCaloricMaintainence + currentMacros.CaloricMaintainanceAdjustment;

            return(Calculate(updatedClientInfo, (int)updatedCaloricMaintainence));
        }