Ejemplo n.º 1
0
        public void SplitAtColonTest()
        {
            var split    = new SplitLines();
            var expected = new string[] { "I", "love", "cats" };
            var actual   = split.SplitLineAtColon("I:love:cats");

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 2
0
        //public List<string> GetAllIngredientNamesFromRatioDatabase(string filename)
        //{
        //    var vw = new VolumeToWeightLogic();
        //    var ListOfRatios = vw.ReadRatiosFromRatioDatabase(filename);
        //    foreach (var ratio in ListOfRatios)
        //    {

        //    }UnalteredResponseDatabase
        //    var CompiledListIngredients = new List<string>();

        //}

        public decimal ReadOuncesForIngredient(string Ingredient, string filename)
        {
            var vw                = new VolumeToWeightLogic();
            var split             = new SplitLines();
            var currentIngredient = split.SplitLineAtColon(vw.ReadIngredientRatio(Ingredient, filename));

            return(Convert.ToDecimal(currentIngredient[1]));
        }
Ejemplo n.º 3
0
        public void SplitSimpleLine()
        {
            var split         = new SplitLines();
            var StringToSplit = "Split this line at the spaces";
            var expected      = new string[] { "Split", "this", "line", "at", "the", "spaces" };

            Assert.AreEqual(expected, split.SplitIngredientLineAtSpaces(StringToSplit));
        }
Ejemplo n.º 4
0
        [Test] //why is this taking only the first character of the first string in the array?
        public void FormatStringWithExtraColon()
        {
            var split    = new SplitLines();
            var test     = "This: That: This other thing: That other things: And this over there";
            var expected = new string[] { " That", " That other things" };
            var actual   = split.ExtraColonInString(test);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 5
0
        public void SplitLinesAtColon()
        {
            var Split      = new SplitLines();
            var actual     = Split.SplitLineAtColon("this:that");
            var SplitArray = new string[] { "this", "that" };
            var expected   = SplitArray;

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 6
0
        public void CountSplitColonTest()
        {
            var split    = new SplitLines();
            var myArray  = new string[] { "this", "that" };
            var actual   = myArray.Count();
            var expected = 2;

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 7
0
        public List <string> ListOfItemResponseRequests()
        {
            var read  = new Reader();
            var split = new SplitLines();
            var GetItemResponseData = new GetIngredientResponse();
            var response            = new ItemResponse();
            var ListOfResponses     = new List <string>();

            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("flour", "10 lb"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("whole wheat flour", "5 lb"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("bread flour", "5 lb"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("Pillsbury Softasilk", "32 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("white sugar", "4 lb"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("brown sugar", "2 lb"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("powdered sugar", "2 lb"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("milk powder", "64 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("cocoa powder", "16 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("baking soda", "4 lb"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("baking powder", "10 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("salt", "26 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("cinnamon", "8.75 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("red star: active dry yeast", "4 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("vegetable oil", "10 lb"));
            //ListOfResponses.Add(GetItemResponseData.GetItemResponsesAndFormatIntoString("milk", "10 lb"));
            //ListOfResponses.Add(GetItemResponseData.GetItemResponsesAndFormatIntoString("eggs", "10 lb"));
            //ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("butter", "10 lb"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("coconut flakes", "14 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("shortening", "48 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("vanilla extract", "8 fl oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("peppermint extract", "2 oz"));
            //ListOfResponses.Add(//GetItemResponseData.GetItemResponseAndFormatIntoString("buttermListOfResponses.Add(ilk", "10 lb");
            //ListOfResponses.Add(//GetItemResponseData.GetItemResponseAndFormatIntoString("cream cheese", "10 lb");
            //ListOfResponses.Add(//GetItemResponseData.GetItemResponseAndFormatIntoString("sour cream", "10 lb");
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("honey", "32 oz"));
            //ListOfResponses.Add(//GetItemResponseData.GetItemResponseAndFormatIntoString("vanilla greek yogurt", "10 lb");
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("carnation sweetened condensed milk", "14 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("organic evaporated milk", "12 fl oz"));
            //ListOfResponses.Add(//GetItemResponseData.GetItemResponseAndFormatIntoString("heavy whipping cream", "10 lb");
            //ListOfResponses.Add(//GetItemResponseData.GetItemResponseAndFormatIntoString("half and half", "10 lb");
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("raisins", "20 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("ocean spray craisins original dried cranberries", "24 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("old fashioned oats", "42 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("semi-sweet chocolate chips", "24 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("semi-sweet chocolate mini", "12 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("milk chocolate chips", "23 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("white chocolate chips", "24 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("bittersweet chocolate baking chips", "10 oz"));
            //ListOfResponses.Add(//GetItemResponseData.GetItemResponseAndFormatIntoString("marshmallows", "10 lb");
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("chopped pecans", "24 oz"));
            ListOfResponses.Add(GetItemResponseData.GetItemResponseAndFormatIntoString("chopped walnuts", "8 oz"));
            return(ListOfResponses);
        }
Ejemplo n.º 8
0
        public List <string> ReadRatiosFromRatioDatabase(string filename)
        {
            var read = new Reader();


            var splitRatio         = new SplitLines();
            var MyRatioDatabase    = read.ReadDatabase(filename);
            var ArrayRatioDatabase = new List <string>();

            foreach (var ratio in MyRatioDatabase)
            {
                ArrayRatioDatabase.Add(ratio);
                //ArrayRatioDatabase.Add(splitRatio.SplitLineAtColon(ratio));
            }
            return(ArrayRatioDatabase);
        }
Ejemplo n.º 9
0
        public decimal CalculateProperFraction(string fraction)
        {
            var split = new SplitLines();
            var SplitFractionAtSlash = split.SplitLineAtSpecifiedCharacter(fraction, '/');
            var NumeratorString      = SplitFractionAtSlash[0];
            var DenominatorString    = SplitFractionAtSlash[1];
            var CalculatedDecimal    = 0m;

            if ((IsStringNumericValue(NumeratorString) && IsStringNumericValue(DenominatorString)) == true)
            {
                var Numerator   = Convert.ToDecimal(NumeratorString);
                var Denominator = Convert.ToDecimal(DenominatorString);
                CalculatedDecimal = Numerator / Denominator;
            }
            return(CalculatedDecimal);
        }
Ejemplo n.º 10
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);
        }
        public string RoundTablespoonMeasurement(string Measurement)
        {
            var Round = new RoundDecimalPlaces();
            var split = new SplitLines();
            var TablespoonsMeasurement       = 0m;
            var RoundedTablespoonMeasurement = "";
            var IngredientLine = split.SplitLineAtSpace(Measurement);

            TablespoonsMeasurement = Convert.ToDecimal(IngredientLine[0]);
            if (TablespoonsMeasurement == 1m)
            {
                RoundedTablespoonMeasurement = Round.RoundToHundrethDecimalPlace(TablespoonsMeasurement) + " tablespoon";
            }
            else
            {
                RoundedTablespoonMeasurement = Round.RoundToHundrethDecimalPlace(TablespoonsMeasurement) + " tablespoons";
            }
            return(RoundedTablespoonMeasurement);
        }
        public string ConvertTeaspoonsToTablespoons(string MeasurementInTeaspoons)
        {
            var Round                        = new RoundDecimalPlaces();
            var ToTablespoons                = new GeneralFunctionality();
            var split                        = new SplitLines();
            var TeaspoonsToTablespoons       = 0m;
            var RoundedTablespoonMeasurement = "";
            var IngredientLine               = split.SplitLineAtSpace(MeasurementInTeaspoons);

            TeaspoonsToTablespoons = ToTablespoons.TeaspoonsToTablespoons(Convert.ToDecimal(IngredientLine[0]));
            if (TeaspoonsToTablespoons == 1m)
            {
                RoundedTablespoonMeasurement = Round.RoundToHundrethDecimalPlace(TeaspoonsToTablespoons) + " tablespoon";
            }
            else
            {
                RoundedTablespoonMeasurement = Round.RoundToHundrethDecimalPlace(TeaspoonsToTablespoons) + " tablespoons";
            }
            return(RoundedTablespoonMeasurement);
        }
Ejemplo n.º 13
0
        public decimal CalculateImproperFraction(string fraction)
        {
            var split = new SplitLines();
            var SplitWholeNumberInFraction = split.SplitLineAtSpace(fraction);
            var SplitFractionAtSlash       = split.SplitLineAtSpecifiedCharacter(SplitWholeNumberInFraction[1], '/');
            var CalculatedDecimal          = 0m;
            var WholeNumberString          = SplitWholeNumberInFraction[0];
            var NumeratorString            = SplitFractionAtSlash[0];
            var DenominatorString          = SplitFractionAtSlash[1];

            if ((IsStringNumericValue(WholeNumberString) && IsStringNumericValue(NumeratorString) && IsStringNumericValue(DenominatorString)) == true)
            {
                var WholeNumber             = Convert.ToDecimal(WholeNumberString);
                var Numerator               = Convert.ToDecimal(NumeratorString);
                var Denominator             = Convert.ToDecimal(DenominatorString);
                var ProperFractionNumerator = (WholeNumber * Denominator) + Numerator;
                CalculatedDecimal = (decimal)ProperFractionNumerator / (decimal)Denominator;
            }
            return(CalculatedDecimal);
        }
Ejemplo n.º 14
0
        public string[] ExtraColonInString(string IngredientNamePriceString)
        {
            var split = new SplitLines();
            var SplitIngredientNamePriceArray = split.SplitLineAtColon(IngredientNamePriceString);
            var NumberOfColons  = IngredientNamePriceString.Count(x => x == ':');
            var IngredientName  = "";
            var IngredientPrice = "";
            var AdjustedIngredientNamePriceArray = new string[2] {
                IngredientName, IngredientPrice
            };

            if (NumberOfColons > 3)
            {
                IngredientName  = SplitIngredientNamePriceArray[1];
                IngredientPrice = SplitIngredientNamePriceArray[3];
                AdjustedIngredientNamePriceArray[0] = IngredientName;
                AdjustedIngredientNamePriceArray[1] = IngredientPrice;
            }
            return(AdjustedIngredientNamePriceArray);
        }
        public string ConvertCupsToTablespoons(string MeasurementInCups)
        {
            var    Round         = new RoundDecimalPlaces();
            var    ToTablespoons = new GeneralFunctionality();
            var    Split         = new SplitLines();
            string RoundedTablespoonMeasurement = "";

            string[] IngredientLine = Split.SplitLineAtSpace(MeasurementInCups);
            //there's something about CupsToTablespoonMeasurement - this is where I am getting the error in the stack trace in all of my failing tests that use this method
            decimal CupsToTablespoonMeasurement = ToTablespoons.CupsToTablespoons(Convert.ToDecimal(IngredientLine[0]));

            if (CupsToTablespoonMeasurement == 1m)
            {
                RoundedTablespoonMeasurement = CupsToTablespoonMeasurement + " tablespoon";
            }
            else
            {
                RoundedTablespoonMeasurement = Round.RoundToHundrethDecimalPlace(CupsToTablespoonMeasurement) + " tablespoons";
            }
            return(RoundedTablespoonMeasurement);
        }
Ejemplo n.º 16
0
        public void GetDeserializedDatabaseData(string ResponseDatabaseFilename)
        {
            var read             = new Reader();
            var split            = new SplitLines();
            var ResponseDatabase = read.ReadDatabase(ResponseDatabaseFilename);
            var LineSplit        = new string[] { };

            foreach (var line in ResponseDatabase)
            {
                if (line.Count(x => x == ':') > 4)
                {
                    LineSplit       = split.SplitLineAtColon(line);
                    IngredientName  = LineSplit[1];
                    IngredientPrice = split.SplitLineAtSpecifiedCharacter(LineSplit[3], '$')[1];
                }
                if (line.Count(x => x == ':') < 5)
                {
                    LineSplit       = split.SplitLineAtColon(line);
                    IngredientName  = LineSplit[0];
                    IngredientPrice = split.SplitLineAtSpecifiedCharacter(LineSplit[2], '$')[1];
                }
                IngredientNamePriceDictionary.Add(IngredientName, IngredientPrice);
            }
        }