Esempio n. 1
0
        public RecipeProjectedOutcome GetRecipeProjectedOutcome(float recipeSize, List <IFermentableIngredient> fermentableIngredients,
                                                                List <IHopIngredient> hopIngredients,
                                                                BeerRecipeCore.Yeast.Yeast yeast, int extractionEfficiency)
        {
            if (recipeSize == 0)
            {
                throw new ArgumentException("Recipe size cannot be zero.", nameof(recipeSize));
            }
            if (fermentableIngredients.Count == 0)
            {
                throw new ArgumentException("There are no fermentable ingredients.", nameof(fermentableIngredients));
            }
            if (hopIngredients.Count == 0)
            {
                throw new ArgumentException("There are no hop ingredients.", nameof(hopIngredients));
            }

            var og = AlcoholUtility.GetOriginalGravity(fermentableIngredients, recipeSize, extractionEfficiency);
            var fg = AlcoholUtility.GetFinalGravity(og, yeast.Characteristics.Attenuation);

            return(new RecipeProjectedOutcome
            {
                Abv = AlcoholUtility.GetAlcoholByVolume(og, fg),
                ColorSrm = (int)Math.Round(ColorUtility.GetColorInSrm(fermentableIngredients, recipeSize), 0, MidpointRounding.ToEven),
                Ibu = BitternessUtility.GetBitterness(hopIngredients, recipeSize, og)
            });
        }
Esempio n. 2
0
 public void UpdateBatchOutcome()
 {
     if (m_recordedGravityReadings.Count > 1)
     {
         AlcoholByVolume = AlcoholUtility.GetAlcoholByVolume((float)m_recordedGravityReadings.First().Value, (float)m_recordedGravityReadings.Last().Value);
         AlcoholByWeight = AlcoholUtility.GetAlcoholByWeight(m_alcoholByVolume);
     }
 }
        public void GetAlcoholByVolumeTest()
        {
            const float originalGravity = 1.045f;
            const float finalGravity    = 1.006f;
            var         actualAbv       = AlcoholUtility.GetAlcoholByVolume(originalGravity, finalGravity);

            actualAbv.Should().Be(5.15f);
        }
Esempio n. 4
0
        public void UpdateRecipeOutcome()
        {
            if (m_size == 0)
            {
                return;
            }

            OriginalGravity = AlcoholUtility.GetOriginalGravity(m_fermentableIngredients, m_size, ExtractionEfficiency);
            if (OriginalGravityStyleComparison != null)
            {
                OriginalGravityStyleComparison.Compare(m_originalGravity);
            }

            if (m_yeastIngredient != null && m_yeastIngredient.YeastInfo != null)
            {
                FinalGravity = AlcoholUtility.GetFinalGravity(m_originalGravity, m_yeastIngredient.YeastInfo.Characteristics.Attenuation);
                if (FinalGravityStyleComparison != null)
                {
                    FinalGravityStyleComparison.Compare(m_finalGravity);
                }
            }

            if (m_finalGravity != 0)
            {
                AlcoholByVolume = AlcoholUtility.GetAlcoholByVolume(m_originalGravity, m_finalGravity);
                if (AbvStyleComparison != null)
                {
                    AbvStyleComparison.Compare(m_alcoholByVolume);
                }
            }

            AlcoholByWeight = AlcoholUtility.GetAlcoholByWeight(m_alcoholByVolume);
            Bitterness      = BitternessUtility.GetBitterness(m_hopsIngredients, m_size, m_originalGravity);
            if (BitternessStyleComparison != null)
            {
                BitternessStyleComparison.Compare(m_bitterness);
            }
            Color = ColorUtility.GetColorInSrm(m_fermentableIngredients, m_size);
            if (ColorStyleComparison != null)
            {
                ColorStyleComparison.Compare((float)m_color);
            }
        }