Beispiel #1
0
        public void Test_negDen_Success()
        {
            Rationals.Program r1  = new Rationals.Program(2, -3);
            Rationals.Program res = new Rationals.Program(-2, 3);

            Assert.AreEqual(res, r1);
        }
Beispiel #2
0
 public void Test_ZeroDen_Failed()
 {
     try
     {
         Rationals.Program r1 = new Rationals.Program(-4, 0);
         Assert.Fail();
     }
     catch (DivideByZeroException) { Assert.IsTrue(true); }
 }
Beispiel #3
0
        public void Test_MulNegative_Success()
        {
            Rationals.Program r1 = new Rationals.Program(-4, 2);
            Rationals.Program r2 = new Rationals.Program(3, 7);
            r1.r1 = r1.Mul(r2.r1);

            Rationals.Program res = new Rationals.Program(-6, 7);
            Assert.AreEqual(res.ToString(), r1.ToString());
        }
Beispiel #4
0
        public void Test_AddNegative_Success()
        {
            Rationals.Program r1 = new Rationals.Program(4, 2);
            Rationals.Program r2 = new Rationals.Program(-3);
            r1.r1 = r1.Add(r2.r1);

            Rationals.Program res = new Rationals.Program(-1);
            Assert.AreEqual(res.ToString(), r1.ToString());
        }
Beispiel #5
0
 public void Test_MulToMuch_Failed()
 {
     Rationals.Program r1 = new Rationals.Program(4, 2);
     Rationals.Program r2 = new Rationals.Program(int.MaxValue);
     try
     {
         r1.r1 = r1.Mul(r2.r1);
         Assert.Fail();
     }
     catch (StackOverflowException)
     {
         Assert.IsTrue(true);
     }
 }
Beispiel #6
0
 public void TestException(Rationals.Program r1, Rationals.Program r2, Exception e1)
 {
     try
     {
         r1.Add(r2.r1);
         Assert.Fail();
     }
     catch (Exception e)
     {
         if (e == e1)
         {
             throw new Exception("wasAnException");
         }
     }
 }
Beispiel #7
0
 public void Test_Equals_Failed()
 {
     Rationals.Program r1 = new Rationals.Program(2, -3);
     Rationals.Program r2 = new Rationals.Program(2, 3);
     Assert.AreEqual(false, r1.Equals(r2));
 }
Beispiel #8
0
 public void Test_Equals_Success()
 {
     Rationals.Program r1 = new Rationals.Program(2, -3);
     Rationals.Program r2 = new Rationals.Program(-2, 3);
     Assert.AreEqual(true, r1.Equals(r2));
 }