Пример #1
0
        public void MyFractionTest_CreatesMyFractionObject()
        {
            MyFraction mf             = new MyFraction();
            string     expectedResult = "EgyptianFractions.MyFraction";
            string     actualResult   = mf.GetType().FullName.ToString();

            Assert.AreEqual(expectedResult, actualResult);
        }
Пример #2
0
        public void DecimalTypeToFractionBravo()
        {
            MyFraction mf             = new MyFraction(0.9);
            string     expectedResult = "9/10";
            string     actualResult   = mf.ToString();

            Assert.AreEqual(expectedResult, actualResult);
        }
Пример #3
0
        public void DecimalEquivalentTest()
        {
            MyFraction mf             = new MyFraction(1, 4);
            decimal    expectedResult = 0.25m;
            decimal    actualResult   = mf.DecimalEquivalent();

            Assert.AreEqual(expectedResult, actualResult);
        }
Пример #4
0
        public void DecimalTypeToFractionAlpha()
        {
            MyFraction mf             = new MyFraction(0.75);
            string     expectedResult = "3/4";
            string     actualResult   = mf.ToString();

            Assert.AreEqual(expectedResult, actualResult);
        }
Пример #5
0
        public void GetImproperFractionTest()
        {
            MyFraction mf             = new MyFraction(4, 3);
            string     expectedResult = "1 1/3";
            string     actualResult   = mf.GetImproperFraction();

            Assert.AreEqual(expectedResult, actualResult);
        }
Пример #6
0
        public void MyFractionTest_CtorDoublesBuildFraction()
        {
            MyFraction mf             = new MyFraction(1, 3);
            string     expectedResult = "1/3";
            string     actualResult   = mf.ToString();

            Assert.AreEqual(expectedResult, actualResult);
        }
Пример #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());
        }
Пример #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);
        }
Пример #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()}");
        }
Пример #10
0
        public void IsImproperTest_False()
        {
            MyFraction mf = new MyFraction(3, 4);

            Assert.IsFalse(mf.IsImproper());
        }
Пример #11
0
        public void IsImproperTest_True()
        {
            MyFraction mf = new MyFraction(4, 3);

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