public void Then_Protein_Energy_Ratio_Is_Correct(PERatioTestCase testData)
        {
            var model = new Food("test")
            {
                Carbohydrates = testData.Carbs,
                Fat           = testData.Fat,
                Fiber         = testData.Fiber,
                Protein       = testData.Protein
            };

            model.PERatio.Should().BeApproximately(testData.ExpectedRatio, 0.00001f);
        }
Beispiel #2
0
        public void Then_Protein_Energy_Ratio_Is_Correct(
            [ValueSource(nameof(PeRatioTestCases))]
            PERatioTestCase testData,
            [Values(0.01f, 0.1f, 1f, 2.5f, 10f)] float servingSize)
        {
            var food = new Food("fake food")
            {
                Carbohydrates = testData.Carbs,
                Fat           = testData.Fat,
                Fiber         = testData.Fiber,
                Protein       = testData.Protein
            };

            var model = new ServingOfFood(food, servingSize);

            model.PERatio.Should().BeApproximately(testData.ExpectedRatio, 0.001f);
        }
Beispiel #3
0
        public void Then_Macronutrients_Are_Multiplied_By_Serving_Size(
            [ValueSource(nameof(PeRatioTestCases))]
            PERatioTestCase testData,
            [Values(0.01f, 0.1f, 1f, 2.5f, 10f)] float servingSize)
        {
            var food = new Food("fake food")
            {
                Carbohydrates = testData.Carbs,
                Fat           = testData.Fat,
                Fiber         = testData.Fiber,
                Protein       = testData.Protein
            };

            var model = new ServingOfFood(food, servingSize);

            using (new AssertionScope())
            {
                model.TotalCarbs.Should().Be(testData.Carbs < 0 ? 0 : testData.Carbs * servingSize);
                model.TotalFat.Should().Be(testData.Fat < 0 ? 0 : testData.Fat * servingSize);
                model.TotalFiber.Should().Be(testData.Fiber < 0 ? 0 : testData.Fiber * servingSize);
                model.TotalProtein.Should().Be(testData.Protein < 0 ? 0 : testData.Protein * servingSize);
            }
        }