예제 #1
0
        public void CosinusTest1()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("cos");
            double           result = calc.Calculation(3.14);

            Assert.AreEqual(result, Math.Cos(3.14));
        }
예제 #2
0
        public void SwapTest1()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("+/-");
            double           result = calc.Calculation(5);

            Assert.AreEqual(result, (-5));
        }
예제 #3
0
        public void LgTest2()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("lg");
            double           result = calc.Calculation(5);

            Assert.AreEqual(result, Math.Log10(5));
        }
예제 #4
0
        public void SinusTest2()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("sin");
            double           result = calc.Calculation(1);

            Assert.AreEqual(result, Math.Sin(1));
        }
예제 #5
0
        public void ArctgTest2()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("arctg");
            double           result = calc.Calculation(3);

            Assert.AreEqual(Math.Atan(3), result);
        }
예제 #6
0
        public void SqrtTest2()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("sqrt");
            double           result = calc.Calculation(9);

            Assert.AreEqual(result, 3);
        }
예제 #7
0
        public void ArccosTest2()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("arccos");
            double           result = calc.Calculation(0.3);

            Assert.AreEqual(result, Math.Acos(0.3));
        }
예제 #8
0
        public void CosTest2()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("cos");
            double           result = calc.Calculation(Math.PI);

            Assert.AreEqual(result, (-1));
        }
예제 #9
0
        public void LnTest1()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("ln");
            double           result = calc.Calculation(1);

            Assert.AreEqual(result, 0);
        }
예제 #10
0
        public void LnTest2()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("ln");
            double           result = calc.Calculation(Math.Pow(Math.E, 2));

            Assert.AreEqual(2, result);
        }
예제 #11
0
        public void ArcsinTest1()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("arcsin");
            double           result = calc.Calculation(1);

            Assert.AreEqual(result, Math.Asin(1));
        }
예제 #12
0
        public void FactorialTest1()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("n!");
            double           result = calc.Calculation(5);

            Assert.AreEqual(result, 120);
        }
예제 #13
0
        public void CtgTest1()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("ctg");
            double           result = calc.Calculation(2);

            Assert.AreEqual(result, 1 / Math.Tan(2));
        }
예제 #14
0
        public void SquareTest1()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("x^2");
            double           result = calc.Calculation(2);

            Assert.AreEqual(result, 4);
        }
예제 #15
0
        public void DelxTest2()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("1/x");
            double           result = calc.Calculation(5);

            Assert.AreEqual(0.2, result);
        }
예제 #16
0
        public void delxTest1()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("1/x");
            double           result = calc.Calculation(2);

            Assert.AreEqual(result, 0.5);
        }
예제 #17
0
        public void FactorialTest2()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("n!");
            double           result = calc.Calculation(7);

            Assert.AreEqual(5040, result);
        }
예제 #18
0
        public void CubedTest1()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("x^3");
            double           result = calc.Calculation(2);

            Assert.AreEqual(result, 8);
        }
예제 #19
0
        public void ArcctgTest2()
        {
            ISingleOperation calc   = SingleOperationFactory.Create("arcctg");
            double           result = calc.Calculation(2);

            Assert.AreEqual(result, Math.PI / 2 - Math.Atan(2));
        }
예제 #20
0
        private void SimpleCalculate(object sender, EventArgs e)
        {
            double doubleFirstArgument = Convert.ToDouble(firstArgument.Text);

            try
            {
                ISingleOperation calculator = SingleOperationFactory.Create(((Button)sender).Text);
                if (firstArgument.Text != "")
                {
                    resultField.Text = calculator.Calculation(doubleFirstArgument).ToString();
                }
            }
            catch (Exception exception)
            {
                resultField.Text = exception.Message;
            }
        }
예제 #21
0
 public void ArccosFailTest()
 {
     ISingleOperation calc   = SingleOperationFactory.Create("arccos");
     double           result = calc.Calculation(-2);
 }
예제 #22
0
 public void DelxTest3()
 {
     ISingleOperation calc   = SingleOperationFactory.Create("1/x");
     double           result = calc.Calculation(0);
 }
예제 #23
0
 public void LnTest3()
 {
     ISingleOperation calc   = SingleOperationFactory.Create("ln");
     double           result = calc.Calculation(-2);
 }