Beispiel #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)
            });
        }
Beispiel #2
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);
            }
        }
        public void GetSpecificAndFinalGravityTest()
        {
            var crystal60InRecipe = new Mock <IFermentableIngredient>();

            crystal60InRecipe.Setup(f => f.Amount).Returns(0.50f);
            crystal60InRecipe.Setup(f => f.FermentableInfo).Returns(new Fermentable("Caramel/Crystal Malt - 60L",
                                                                                    new FermentableCharacteristics(74, 60, 0)
            {
                Type = FermentableType.Grain, GravityPoint = 34
            }, "Test Notes", "US"));

            var chocolateMaltInRecipe = new Mock <IFermentableIngredient>();

            chocolateMaltInRecipe.Setup(f => f.Amount).Returns(1);
            chocolateMaltInRecipe.Setup(f => f.FermentableInfo).Returns(new Fermentable("Chocolate Malt",
                                                                                        new FermentableCharacteristics(60, 350, 0)
            {
                Type = FermentableType.Grain, GravityPoint = 28
            }, "Test Notes", "US"));

            var marisOtterInRecipe = new Mock <IFermentableIngredient>();

            marisOtterInRecipe.Setup(f => f.Amount).Returns(8);
            marisOtterInRecipe.Setup(f => f.FermentableInfo).Returns(new Fermentable("Pale Malt, Maris Otter",
                                                                                     new FermentableCharacteristics(82.5f, 3, 120)
            {
                Type = FermentableType.Grain, GravityPoint = 38
            }, "Test Notes", "US"));

            var fermentablesInRecipe = new List <IFermentableIngredient> {
                crystal60InRecipe.Object, chocolateMaltInRecipe.Object, marisOtterInRecipe.Object
            };
            var actualSpecificGravity = AlcoholUtility.GetOriginalGravity(fermentablesInRecipe, 5, 70);

            actualSpecificGravity.Should().Be(1.049f);
            var actualFinalGravity = AlcoholUtility.GetFinalGravity(actualSpecificGravity, 75);

            actualFinalGravity.Should().Be(1.012f);
        }