public void CalculatePercentage2() { var vw = new VolumeToWeightLogic(); var expected = .8m; var actual = vw.PercentageOfMeasuredCupsToStandardCups(("4/5")); Assert.AreEqual(expected, actual); }
//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])); }
public decimal GetAmountOfOuncesUsed(string Ingredient, string measuredCups, string filename) { var vw = new VolumeToWeightLogic(); var divide = new GeneralFunctionality(); var GetOuncesForIngredient = vw.ReadOuncesForIngredient(Ingredient, filename); var GetPercentMeasuredCupsToStandardCups = vw.PercentageOfMeasuredCupsToStandardCups(measuredCups); return(GetPercentMeasuredCupsToStandardCups * GetOuncesForIngredient); }
public void ReadOuncesForWhiteSugar() { var vw = new VolumeToWeightLogic(); var filename = @"C:\Users\Rachel\Documents\Visual Studio 2015\Projects\RachelsRoses\Rachel-s-Roses\VolumeToWeightIngredientData.txt"; var expected = 7.1m; var actual = vw.ReadOuncesForIngredient("white sugar", filename); Assert.AreEqual(expected, actual); }
public void ReadSpecificIngredient() { var vw = new VolumeToWeightLogic(); var filename = @"C:\Users\Rachel\Documents\Visual Studio 2015\Projects\RachelsRoses\Rachel-s-Roses\VolumeToWeightIngredientData.txt"; var expected = "salt: 10.72"; // new string[] { "salt", "10.72" }; var actual = vw.ReadIngredientRatio("salt", filename); Assert.AreEqual(expected, actual); }
public void CalculateOuncesForSixAndAnEighthCups() { var vw = new VolumeToWeightLogic(); var filename = @"C:\Users\Rachel\Documents\Visual Studio 2015\Projects\RachelsRoses\Rachel-s-Roses\VolumeToWeightIngredientData.txt"; var expected = 31.25m; var actual = vw.GetAmountOfOuncesUsed("flour", "6.25", filename); Assert.AreEqual(expected, actual); }
public void CalculateOuncesForOneAndAHalfCupsBananas() { var vw = new VolumeToWeightLogic(); var filename = @"C:\Users\Rachel\Documents\Visual Studio 2015\Projects\RachelsRoses\Rachel-s-Roses\VolumeToWeightIngredientData.txt"; var expected = 18m; var actual = vw.GetAmountOfOuncesUsed("bananas", "1.5", filename); Assert.AreEqual(expected, actual); }
public void ReadOuncesForVanillaExtract() { var vw = new VolumeToWeightLogic(); var filename = @"C:\Users\Rachel\Documents\Visual Studio 2015\Projects\RachelsRoses\Rachel-s-Roses\VolumeToWeightIngredientData.txt"; var expected = 6.86m; var actual = vw.ReadOuncesForIngredient("vanilla", filename); Assert.AreEqual(expected, actual); }
public void ConcatStringsWithColon() { var vol2weight = new VolumeToWeightLogic(); var array = new string[] { }; var expected = "Something" + " : " + 4m; var actual = vol2weight.ConcatRatioArray("Something", 4m.ToString()); Assert.AreEqual(expected, actual); }
//public static Func<string, string, decimal, decimal, decimal> DeterminePriceForStandardMeasuredIngredient // = (name, sizeBoughtInPounds, ouncesPerStandard, price) => (ouncesPerStandard / (Convert.ToDecimal(sizeBoughtInPounds) * 16)) * price; ///* // To do next: // get price per ounce // will have to know if item is sold in pounds/gallons/ounces, and do logic to determine price per ounce // multiply price per ounce by how many ounces of an ingredient i used //*/ //public decimal ConvertToOunces(string ProductName) //{ // var convertToOunces = new GeneralFunctionality(); // if ((ProductName.ToLower()).Contains("lb") || (ProductName.ToLower().Contains("pound"))) // { // } // "oz" // "gallons" // "pint" // "egg" //public void DetermineIfNameHasLbs(string Ingredient) //{ // //Pillsbury Flour 10 lb //} //public static decimal PricePerOunceUsed(string Ingredient, string MeasuredCups, string filename) //{ // var CalculateOunces = new VolumeToWeightLogic(); // var response = new ItemResponse(); // var priceForItem = response.SalePrice; // var standardOunceForIngredient = CalculateOunces.ReadOuncesForIngredient(Ingredient, filename); // var measuredOunces = CalculateOunces.GetAmountOfOuncesUsed(Ingredient, MeasuredCups, filename); //} //get price for 1 cup of ingredient //determine percent of standard based on how many cups (just multiply the ounces by the measured cups) public decimal DeterminePriceForOuncesUsed(string Ingredient, string MeasuredCups, string filename) { //this is just a super long way of saying when I use 2 1/2 c of flour, i use 2.5x the standard amount... var GetOunces = new VolumeToWeightLogic(); var response = new ItemResponse(); var price = response.SalePrice; var standardOuncesForIngredient = GetOunces.ReadOuncesForIngredient(Ingredient, filename); var MeasuredOunces = GetOunces.GetAmountOfOuncesUsed(Ingredient, MeasuredCups, filename); var Percentage = MeasuredOunces / standardOuncesForIngredient; return(Percentage); }
public string ReadIngredientRatio(string Ingredient, string filename) { var vw = new VolumeToWeightLogic(); var ListOfRatios = vw.ReadRatiosFromRatioDatabase(filename); var currentIngredient = ""; // new string[] { }; for (int line = 0; line < ListOfRatios.Count; line++) { if (ListOfRatios[line].Contains(Ingredient)) { currentIngredient = ListOfRatios[line]; } } return(currentIngredient); }
/* * 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); }