Ejemplo n.º 1
0
        public void TestSTringIfNumeric3()
        {
            var testString = new GeneralFunctionality();
            var expected   = false;
            var actual     = testString.IsStringNumericValue("flour");

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 2
0
        public void IsStringAValidNumber()
        {
            var test     = new GeneralFunctionality();
            var expected = true;
            var actual   = test.IsStringNumericValue("11.98");

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 3
0
        public void TestingIfStringIsNumeric()
        {
            var testString = new GeneralFunctionality();
            var expected   = true;
            var actual     = testString.IsStringNumericValue("1345642");

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 4
0
        /*
         * get price per ounce for gallons
         * get price per ounce for ounces
         * get price per ounce for lbs
         */
        // public decimal PricePerGallon(string Ingredient, string UnitOfMeasurement, string VolumeToWeightRatioDatabaseFilename, string ResponseDatabaseFilename)
        //{
        //    var read = new Reader();
        //    var RatioDatabse = read.ReadDatabase(VolumeToWeightRatioDatabaseFilename);
        //    var ResponseDatabase = read.ReadDatabase(ResponseDatabaseFilename);
        //    for (int i = 0; i < ResponseDatabase.Count(); i++)
        //    {
        //        if (ResponseDatabase[i].Contains(Ingredient) && ResponseDatabase[i].Contains(UnitOfMeasurement))
        //        {
        //            for (int j = 0; j < RatioDatabse.Count(); j++)
        //            {
        //                if (RatioDatabse[j].Contains(Ingredient}
        //        }
        //        {

        //        }))
        //            }
        //        }
        //    }

        public decimal GetPriceForOneOunceOfIngredient(string Ingredient, string VolumeToWeightRatioDatabase, string ResponseDatabaseFilename)
        {
            var read           = new Reader();
            var split          = new SplitLines();
            var GetOunces      = new VolumeToWeightLogic();
            var convertToNmber = new GeneralFunctionality();
            var IngredientVolumeToWeightRatios = read.ReadDatabase(VolumeToWeightRatioDatabase);
            var UnalteredResponseDatabase      = read.ReadDatabase(ResponseDatabaseFilename);
            var IngredientPrice = 0m;
            //var ParsedNumberString = 0m;IngredientName, IngredientPrice
            var CalculatedOunces = 0m;
            //var OuncesForStandardMeasuredIngredient = 0m;
            var PricePerOunce = 0m;

            for (int i = 0; i < UnalteredResponseDatabase.Count(); i++)
            {
                if (UnalteredResponseDatabase[i].Contains(Ingredient))
                {
                    IngredientPrice = GetPriceForIndividualIngredient(Ingredient); //, ResponseDatabaseFilename);
                    for (int j = 0; j < IngredientVolumeToWeightRatios.Count(); j++)
                    {
                        if (IngredientVolumeToWeightRatios[j].Contains(Ingredient))
                        {
                            if (UnalteredResponseDatabase[i].ToLower().Contains(("oz")))
                            {
                                var FindNumbers = split.SplitLineAtSpace(UnalteredResponseDatabase[i]);
                                foreach (var array in FindNumbers)
                                {
                                    decimal output;
                                    if (convertToNmber.IsStringNumericValue(array) == true)
                                    {
                                        Decimal.TryParse(array, out output);//memory representaion, keeping a file in memory to get the values... it's a memory manager ... it's a data structure manager that manages the memory of that files
                                        CalculatedOunces = output;
                                    }
                                }
                            }
                            //.Cgallons, lbs || pounds, oz, //)
                            //OuncesForStandardMeasuredIngredient = GetOunces.ReadOuncesForIngredient(Ingredient, VolumeToWeightRatioDatabase);
                        }//how many cups are in the bag of whatever is sold, then do the math with the ounces
                    }
                }
            }
            PricePerOunce = IngredientPrice / CalculatedOunces;
            return(PricePerOunce);
        }