public void TestImproperFraction()
        {
            var fraction = new GeneralFunctionality();
            var expected = 2.5m;
            var actual   = fraction.CalculateDecimalFromFraction("2 1/2");

            Assert.AreEqual(expected, actual);
        }
        public void CalculateDecimalOfOneEighth()
        {
            var fractionToDecimal = new GeneralFunctionality();
            var expected          = .125m;
            var actual            = fractionToDecimal.CalculateDecimalFromFraction("1/8");

            Assert.AreEqual(expected, actual);
        }
        public void TestDivisionFractions2()
        {
            var divide   = new GeneralFunctionality();
            var expected = .278m;
            var actual   = divide.CalculateDecimalFromFraction("5/18");

            Assert.AreEqual(expected, actual);
        }
        public void TestNonNumericFraction()
        {
            var fraction = new GeneralFunctionality();
            var expected = 0m;
            var actual   = fraction.CalculateDecimalFromFraction("2 b/r");

            Assert.AreEqual(expected, actual);
        }
Esempio n. 5
0
        public decimal PercentageOfMeasuredCupsToStandardCups(string measuredCups)
        {
            var divide = new GeneralFunctionality();

            if (measuredCups.Contains('/'))
            {
                return(divide.CalculateDecimalFromFraction(measuredCups));
            }
            else
            {
                return((Convert.ToDecimal(measuredCups)) / 1);
            }
        }