예제 #1
0
        public void ApplyBitterToRecipe()
        {
            RecipeFactory     myFactory           = new RecipeFactory();
            IRecipe           myRecipe            = myFactory.GetRecipe(RecipeTypes.Beer);
            IngredientFactory myIngredientFactory = new IngredientFactory();
            var ingredient = myIngredientFactory.GetIngredient(IngredientType.Fermentable);

            ingredient.Amount = 10;
            (ingredient as IFermentable).DiastaticPower = 1.04;
            myRecipe.Ingredients.Add(ingredient);
            //adding bitters is just a test for my sanity in querying interfaces and dealing with Covariance
            //note it will be repeated on the IBU calculation as the fermentable power impacts bitterness
            ingredient        = myIngredientFactory.GetIngredient(IngredientType.BitterSeason);
            ingredient.Amount = 1.5;
            (ingredient as IBitter).BitteringFactor       = 15;
            (ingredient as IBitter).BitterCalculationTime = 60;
            myRecipe.Ingredients.Add(ingredient);
            myRecipe.BatchVolume            = 6.5;
            myRecipe.TotalEfficiencyPercent = 70;
            var ibus = myRecipe.GetEstimatedBitterness();

            Assert.AreEqual(myRecipe.Bitters.Count, 1);
            //May need to check formula.  BeerSmith usually is a little higher.  BeerSmith has been known to tweak their forumulas though.
            Assert.AreEqual(63.81, Math.Round(ibus, 2));
        }
예제 #2
0
        public GameSession()
        {
            CurrentLocation = CurrentWorld.LocationAt(0, 0);

            CurrentPlayer = new Player("Test", "Fighter", 10, gold: 1000);
            CurrentPlayer.AddToInventory(ItemFactory.NewItem(1001));
            CurrentPlayer.AddToInventory(ItemFactory.NewItem(2001));
            CurrentPlayer.LearnRecipe(RecipeFactory.GetRecipe(1));
        }
예제 #3
0
        private static string RunRecipe(ConfigurationContainer config, ILogger logger)
        {
            var tempFilePath = Path.GetTempFileName();

            logger?.Trace("Temporary file path is {0} ...", tempFilePath);

            var recipe = RecipeFactory.GetRecipe(config);

            recipe.DownloadFile(tempFilePath, logger);

            return(tempFilePath);
        }
예제 #4
0
        public void CreateNewRecipe()
        {
            RecipeFactory myFactory = new RecipeFactory();
            IRecipe       myRecipe  = myFactory.GetRecipe(RecipeTypes.Beer);

            myRecipe.BatchVolume            = 6.5;
            myRecipe.Name                   = "My Beer Name";
            myRecipe.TotalEfficiencyPercent = 70;
            myRecipe.Style                  = new Style();
            IngredientFactory myIngredientFactory = new IngredientFactory();

            myRecipe.Ingredients.Add(myIngredientFactory.GetIngredient(IngredientType.Fermentable));
            myRecipe.BatchVolume = 6.5;
            Assert.AreEqual(1, myRecipe.Ingredients.Count);
        }
예제 #5
0
        public void ApplyFermentableToRecipe()
        {
            RecipeFactory     myFactory           = new RecipeFactory();
            IRecipe           myRecipe            = myFactory.GetRecipe(RecipeTypes.Beer);
            IngredientFactory myIngredientFactory = new IngredientFactory();
            var ingredient = myIngredientFactory.GetIngredient(IngredientType.Fermentable);

            ingredient.Amount = 10;
            (ingredient as IFermentable).DiastaticPower = 1.04;
            myRecipe.Ingredients.Add(ingredient);
            //adding bitters is just a test for my sanity in querying interfaces and dealing with Covariance
            //note it will be repeated on the IBU calculation as the fermentable power impacts bitterness
            ingredient        = myIngredientFactory.GetIngredient(IngredientType.BitterSeason);
            ingredient.Amount = 1.5;
            myRecipe.Ingredients.Add(ingredient);
            myRecipe.BatchVolume            = 6.5;
            myRecipe.TotalEfficiencyPercent = 70;
            var og = myRecipe.GetEstimatedOriginalGravity();

            Assert.AreEqual(myRecipe.Fermentables.Count, 1);
            Assert.AreEqual(Math.Round(og, 3), 1.043);
        }
예제 #6
0
        public void ApplyFermenterToRecipe()
        {
            RecipeFactory     myFactory           = new RecipeFactory();
            IRecipe           myRecipe            = myFactory.GetRecipe(RecipeTypes.Beer);
            IngredientFactory myIngredientFactory = new IngredientFactory();
            var ingredient = myIngredientFactory.GetIngredient(IngredientType.Fermentable);

            ingredient.Amount = 10;
            (ingredient as IFermentable).DiastaticPower = 1.04;
            myRecipe.Ingredients.Add(ingredient);
            myRecipe.BatchVolume            = 6.5;
            myRecipe.TotalEfficiencyPercent = 70;
            var og = myRecipe.GetEstimatedOriginalGravity();

            Assert.AreEqual(myRecipe.Fermentables.Count, 1);
            Assert.AreEqual(Math.Round(og, 3), 1.043);
            ingredient = myIngredientFactory.GetIngredient(IngredientType.Fermenter);
            (ingredient as IFerment).PitchType   = FermenterPitchType.Dry;
            (ingredient as IFerment).Attenuation = 75;
            myRecipe.Ingredients.Add(ingredient);
            var fg = myRecipe.GetEstimatedFinalGravity();

            Assert.AreEqual(Math.Round(fg, 3), 1.011);
        }
예제 #7
0
        private static void Main()
        {
            var logger = new Logger();

            try
            {
                logger.Info("Erbsenzähler AutoImporter starting ...");

                #region Configuration

                logger.Trace("Looking for configuration file ...");
                var configPath = Path.Combine(Environment.CurrentDirectory, "config.json");
                if (!File.Exists(configPath))
                {
                    logger.Fatal("Unable to locate configuration file at " + configPath + ".");
                    Environment.Exit(-1);
                }

                logger.Trace("Loading configuration ...");
                try
                {
                    Configuration = JsonConvert.DeserializeObject <IEnumerable <ConfigurationContainer> >(File.ReadAllText(configPath)).ToList();
                }
                catch (Exception ex)
                {
                    logger.Fatal("Unable to parse configuration file: ");
                    logger.Fatal(ex.Message);
                    Environment.Exit(-2);
                }

                #endregion

                var configCount = 0;
                foreach (var config in Configuration)
                {
                    logger.Info("Running import " + ++configCount + " of " + Configuration.Count() + " ...");

                    var tempFilePath = Path.GetTempFileName();
                    logger.Trace("Temporary file path is {0} ...", tempFilePath);

                    var recipe = RecipeFactory.GetRecipe(config);
                    recipe.DownloadFile(tempFilePath, logger);

                    if (File.Exists(tempFilePath) && new FileInfo(tempFilePath).Length > 0)
                    {
                        var uploader = new ErbsenzaehlerUploader(config.Erbsenzaehler);
                        uploader.Upload(tempFilePath, logger);
                    }

                    if (File.Exists(tempFilePath))
                    {
                        logger.Trace("Deleting temporary file {0} ...", tempFilePath);
                        File.Delete(tempFilePath);
                    }
                }

                logger.Info("Quitting ...");
            }
            catch (Exception ex)
            {
                logger.Fatal(ex.ToString());
            }
        }