Пример #1
0
        public void CutTest2(int num, int denom)
        {
            var sf1 = new SimpleFraction(num, denom);

            sf1.Cut(2);
            Assert.AreEqual(new SimpleFraction(num, denom), sf1);
        }
Пример #2
0
        public void SimpleFractionMathActionTest()
        {
            Assert.AreEqual("29/12", (sf + sf2).ToString());
            Assert.AreEqual("13/12", (sf2 - sf).ToString());
            Assert.AreEqual("14/12", (sf2 * sf).ToString());
            Assert.AreEqual("8/21", (sf / sf2).ToString());
            Assert.AreEqual("11/3", (sf + 3).ToString());
            Assert.AreEqual(new SimpleFraction(-5, 4), sf2 - 3);
            Assert.AreEqual("21/4", (sf2 * 3).ToString());
            Assert.AreEqual("2/9", (sf / 3).ToString());
            Assert.AreEqual("11/3", (3 + sf).ToString());
            Assert.AreEqual("5/4", (3 - sf2).ToString());
            Assert.AreEqual("21/4", (3 * sf2).ToString());
            Assert.AreEqual("9/2", (3 / sf).ToString());

            sf3.Cut();
            Assert.AreEqual("3/2", sf3.ToString());

            Assert.AreEqual("2/5", new SimpleFraction("5/2").Reverse().ToString());

            Assert.AreEqual(true, new SimpleFraction(2, 3) > new SimpleFraction(1, 3));
            Assert.AreEqual(true, new SimpleFraction(5, 7) > new SimpleFraction(1, 20));
            Assert.AreEqual(true, new SimpleFraction(12, 7) > new SimpleFraction(1, 20));
            Assert.AreEqual(true, new SimpleFraction(12, 7) == new SimpleFraction(12, 7));
            Assert.AreEqual(true, new SimpleFraction(12, 7) != new SimpleFraction(1, 20));
            Assert.AreEqual(false, new SimpleFraction(12, 7) < new SimpleFraction(1, 20));
            Assert.AreEqual(false, new SimpleFraction(5, 7) < new SimpleFraction(1, 20));
            Assert.AreEqual(false, new SimpleFraction(12, 7) < new SimpleFraction(1, 20));
        }