public void TestingInts()
        {
            var round    = new RoundDecimalPlaces();
            var actual   = round.RoundToHundrethDecimalPlace(4.000345m);
            var expected = "4";

            Assert.AreEqual(expected, actual);
        }
        public void TestingSingleDecimalPlacesAgain()
        {
            var round    = new RoundDecimalPlaces();
            var actual   = round.RoundToHundrethDecimalPlace(145.04723432m);
            var expected = "145";

            Assert.AreEqual(expected, actual);
        }
        public void TestingSingleDecimalPlacesAgainAgain()
        {
            var round    = new RoundDecimalPlaces();
            var actual   = round.RoundToHundrethDecimalPlace(135);
            var expected = "135";

            Assert.AreEqual(actual, expected);
        }
        public void TestingDecimalsWithOneSpace()
        {
            var round    = new RoundDecimalPlaces();
            var actual   = round.RoundToHundrethDecimalPlace(2.5m);
            var expected = "2.5";

            Assert.AreEqual(expected, actual);
        }
        public void TestSingleDecimalPlace2()
        {
            var round    = new RoundDecimalPlaces();
            var actual   = round.RoundToHundrethDecimalPlace(5.06m);
            var expected = "5";

            Assert.AreEqual(expected, actual);
        }
        public void TestDecimalPlaces2()
        {
            var round    = new RoundDecimalPlaces();
            var actual   = round.RoundToHundrethDecimalPlace(135.60m);
            var expected = "135.6";

            Assert.AreEqual(expected, actual);
        }
        public void TestDecimalPlaces()
        {
            var decimalized = new RoundDecimalPlaces();
            var actual      = decimalized.RoundToHundrethDecimalPlace(125.65239845m);
            var expected    = "125.65";

            Assert.AreEqual(expected, actual);
        }
        public void TestingDecimalsUnder1()
        {
            var round    = new RoundDecimalPlaces();
            var actual   = round.RoundToHundrethDecimalPlace(0.5678m);
            var expected = ".57";

            Assert.AreEqual(expected, actual);
        }
Beispiel #9
0
        public void TestingMoreDecimals()
        {
            var round    = new RoundDecimalPlaces();
            var actual   = round.RoundToHundrethDecimalPlace(150.40m);
            var expected = "150.4";

            Assert.AreEqual(expected, actual);
        }
        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);
        }
        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);
        }
Beispiel #13
0
        public List <string> GetIngredientMeasurement(string filename)
        {
            var DecimalPlaces         = new RoundDecimalPlaces();
            var ReadMyFile            = new Reader();
            var ConvertToTablespoons  = new ConvertToTablespoons();
            var Ingredient            = new string[] { };
            var IngredientMeasurement = "0";
            var MyFile = ReadMyFile.ReadRecipe(filename);
            var RecipeWithoutMeasurementUnits = new List <string>();
            var RoundedIngredientMeasurement  = "";

            foreach (var line in MyFile)
            {
                Ingredient = line.Split(' '); //Ingredient is the array that is returned from the string split
                if (line.Contains("cup"))
                {
                    IngredientMeasurement = ConvertToTablespoons.CupsToTablespoons(Convert.ToDecimal(Ingredient[0])).ToString();
                    Console.WriteLine(IngredientMeasurement);
                }
                if (line.Contains("tablespoon"))
                {
                    IngredientMeasurement = Int32.Parse(Ingredient[0].ToString()).ToString();
                    Console.WriteLine(IngredientMeasurement);
                }
                if (line.Contains("teaspoon"))
                {
                    IngredientMeasurement = ConvertToTablespoons.TeaspoonsToTablespoons(Convert.ToDecimal(Ingredient[0])).ToString();
                    Console.WriteLine(IngredientMeasurement);
                }
                if (!line.Contains("cup") || line.Contains("tablespoon") || line.Contains("teaspoon"))
                {
                    IngredientMeasurement = Ingredient[0].ToString();
                    Console.WriteLine(IngredientMeasurement);
                }
                RoundedIngredientMeasurement = DecimalPlaces.RoundToHundrethDecimalPlace(Convert.ToDecimal(IngredientMeasurement));
                RecipeWithoutMeasurementUnits.Add(RoundedIngredientMeasurement);
            }
            return(RecipeWithoutMeasurementUnits);
        }