Exemplo n.º 1
0
        public void Test()
        {
            for (int x = 0; x <= 20; x++)
            {
                for (int y = 0; y <= 20; y++)
                {
                    Calculator.Methods s = new Calculator.Methods();

                    s.multiplication(x, y);
                    var a = s.multiplication(x, y);
                    Assert.IsTrue(x * y == a, "При x = {0} и y = {1} получили = {2}", x, y, a);


                    s.addition(x, y);
                    var b = s.addition(x, y);
                    Assert.IsTrue(x + y == b, "При x = {0} и y = {1} получили = {2}", x, y, b);

                    s.difference(x, y);
                    var c = s.difference(x, y);
                    Assert.IsTrue(x - y == c, "При x = {0} и y = {1} получили = {2}", x, y, c);

                    s.division(x, y);
                    var d = s.division(x, y);

                    if (y == 0)
                    {
                        Assert.Pass();
                    }
                    else
                    {
                        Assert.IsTrue(x / y == d, "При x = {0} и y = {1} получили = {2}", x, y, d);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void difference(double x, double y)
        {
            Calculator.Methods operation = new Calculator.Methods();
            var result = operation.difference(x, y);

            Assert.AreEqual(x - y, result, "wrong test {0} - {1} = {2}", x, y, result);
        }
        public void Test_dif(double x, double y)
        {
            Calculator.Methods c   = new Calculator.Methods();
            double             dif = c.difference(x, y);

            Assert.IsTrue(x - y == dif, "ќшибка при вычитании: (x={0}) - (y={1}) ={2}", x, y, dif);
        }
Exemplo n.º 4
0
        public void DIF(int x, int y)
        {
            Calculator.Methods k  = new Calculator.Methods();
            double             a1 = k.difference(x, y);
            double             a2 = x - y;

            Assert.IsTrue(a1 == a2, "x - y = {0}, метод = {1}", a2, a1);
        }
Exemplo n.º 5
0
        public void Test2(double x, double y)
        {
            Calculator.Methods raz = new Calculator.Methods();

            double R = raz.difference(x, y);
            double b = x - y;

            Assert.IsTrue(b == R, "Ďđč x = {0} č y = {1}, ďîëó÷čëč R = {2}", x, y, R);
        }
Exemplo n.º 6
0
        public void Test_Diff(
            [Range(0, 20)] double x,
            [Range(0, 20)] double y)
        {
            Calculator.Methods s = new Calculator.Methods();
            double             a = s.difference(x, y);
            double             r = x - y;

            Assert.AreEqual(r, a, "При X = {0}, Y = {1},\n  Результат вычитания = {2},\n  Ожидаемый результат = {3}", x, y, a, r);
        }
Exemplo n.º 7
0
        public void Test1()
        {
            for (double x = 1; x <= 20; x++)
            {
                for (double y = 1; y <= 20; y++)
                {
                    //double x = 2;
                    //double y = 14;
                    Calculator.Methods k = new Calculator.Methods();
                    k.addition(x, y);
                    var s = k.addition(x, y);
                    Assert.IsTrue(x + y == s, "ѕеременна¤ x= {0}, y= {1}, —умма чисел ровна:{2} а должна быть ровна {3}", x, y, s, x + y);

                    k.difference(x, y);
                    var o = k.difference(x, y);
                    Assert.IsTrue(x - y == o, "ѕеременна¤ x= {0}, y= {1}, –азность чисел ровна:{2} а должна быть ровна {3}", x, y, o, x - y);

                    k.division(x, y);
                    var d = k.division(x, y);

                    if (y == 0)
                    {
                        Assert.Pass();
                    }
                    else
                    {
                        Assert.IsTrue(x / y == d, "ѕеременна¤ x= {0}, y= {1}, –езультат делени¤ чисел равен:{2} а должна быть ровна {3}", x, y, d, x / y);
                    }


                    k.multiplication(x, y);
                    var m = k.multiplication(x, y);
                    Assert.IsTrue(x * y == m, "ѕеременна¤ x= {0}, y= {1}, –езультат умножени¤ чисел равен:{2} а должна быть ровна {3}", x, y, d, x * y);
                }
            }
        }
Exemplo n.º 8
0
        public void Test2()
        {
            Calculator.Methods n = new Calculator.Methods();

            var x = Enumerable.Range(0, 20); //заменяется на (9, 20);
            var y = Enumerable.Range(0, 20); //заменяется на (11, 20);

            foreach (int a in x)
            {
                foreach (int b in y)
                {
                    double result = n.difference(a, b);
                    Assert.AreEqual(a - b, result, "{0} - {1} = {2}", a, b, result);
                }
            }
        }
Exemplo n.º 9
0
 [Test, TestCaseSource("DivideCases")]       // Тесты на вычитание
 public void TestDiff(int a, int b)
 {
     Calculator.Methods s = new Calculator.Methods();
     Assert.AreEqual((a - b), s.difference(a, b), "При вычитании {1} из {0} получили {2}", a, b, s.division(a, b));
 }
Exemplo n.º 10
0
 public void Test3(double x, double y)
 {
     Assert.AreEqual(x - y, a.difference(x, y), "разность");
 }