Exemplo n.º 1
0
        public void MyFractionTest_CreatesMyFractionObject()
        {
            MyFraction mf             = new MyFraction();
            string     expectedResult = "EgyptianFractions.MyFraction";
            string     actualResult   = mf.GetType().FullName.ToString();

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemplo n.º 2
0
        public void DecimalTypeToFractionBravo()
        {
            MyFraction mf             = new MyFraction(0.9);
            string     expectedResult = "9/10";
            string     actualResult   = mf.ToString();

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemplo n.º 3
0
        public void DecimalEquivalentTest()
        {
            MyFraction mf             = new MyFraction(1, 4);
            decimal    expectedResult = 0.25m;
            decimal    actualResult   = mf.DecimalEquivalent();

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemplo n.º 4
0
        public void DecimalTypeToFractionAlpha()
        {
            MyFraction mf             = new MyFraction(0.75);
            string     expectedResult = "3/4";
            string     actualResult   = mf.ToString();

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemplo n.º 5
0
        public void GetImproperFractionTest()
        {
            MyFraction mf             = new MyFraction(4, 3);
            string     expectedResult = "1 1/3";
            string     actualResult   = mf.GetImproperFraction();

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemplo n.º 6
0
        public void MyFractionTest_CtorDoublesBuildFraction()
        {
            MyFraction mf             = new MyFraction(1, 3);
            string     expectedResult = "1/3";
            string     actualResult   = mf.ToString();

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemplo n.º 7
0
        public void Test_GreedyAlgo_Alpha()
        {
            string     expectedResult = "2/1";
            MyFraction f1             = new MyFraction(8, 11);
            MyFraction result         = new MyFraction(MyEgyptianFractions.GreedyAlgo(f1.Numerator, f1.Denominator));

            Console.WriteLine(result.ToString());
            Assert.AreEqual(expectedResult, result.ToString());
        }
Exemplo n.º 8
0
        public void DifferenceTest()
        {
            MyFraction mf1            = new MyFraction(1, 2);
            MyFraction mf2            = new MyFraction(3, 4);
            string     expectedResult = "1/4";
            MyFraction mfDiff         = mf1.Difference(mf2);
            string     actualResult   = mfDiff.ToString();

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemplo n.º 9
0
        public void Test_FractionSplitter_Alpha()
        {
            string     expectedResult = "2/11, 6/11";
            MyFraction f1             = new MyFraction(8, 11);
            MyFraction result         = new MyFraction();
            MyFraction fraction2      = null;

            result = MyEgyptianFractions.FractionSplitter(f1, out fraction2);
            Console.WriteLine(result.ToString());
            Assert.AreEqual(expectedResult, $"{result.ToString()}, {fraction2.ToString()}");
        }
Exemplo n.º 10
0
        public void IsImproperTest_False()
        {
            MyFraction mf = new MyFraction(3, 4);

            Assert.IsFalse(mf.IsImproper());
        }
Exemplo n.º 11
0
        public void IsImproperTest_True()
        {
            MyFraction mf = new MyFraction(4, 3);

            Assert.IsTrue(mf.IsImproper());
        }