Exemplo n.º 1
0
        public void CosShouldReturnCorrectResult()
        {
            var func          = new Cos();
            var args          = FunctionsHelper.CreateArgs(2);
            var result        = func.Execute(args, _parsingContext);
            var roundedResult = Math.Round((double)result.Result, 9);

            Assert.AreEqual(-0.416146837d, roundedResult);
        }
        public void DoubleFunctionCos()
        {
            var sut    = new Cos();
            var result = sut.Execute(new List <Accumulator> {
                new Accumulator(Math.PI / 3)
            });

            Assert.AreEqual(Math.Cos(Math.PI / 3), result.ValueAsDouble());
        }
Exemplo n.º 3
0
        public void CosWithInvalidArgumentReturnsPoundValue()
        {
            var func           = new Cos();
            var parsingContext = ParsingContext.Create();
            var args           = FunctionsHelper.CreateArgs();
            var result         = func.Execute(args, parsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type);
        }
Exemplo n.º 4
0
        public void ExecuteComplexNumberTest()
        {
            var complex = new Complex(3, 2);
            var exp     = new Cos(new ComplexNumber(complex));
            var result  = (Complex)exp.Execute();

            Assert.Equal(Complex.Cos(complex), result);
            Assert.Equal(-3.7245455049153224, result.Real, 14);
            Assert.Equal(-0.51182256998738462, result.Imaginary, 14);
        }
Exemplo n.º 5
0
        public void ExecuteTestException()
        {
            var exp = new Cos(new Bool(false));

            Assert.Throws <ResultIsNotSupportedException>(() => exp.Execute());
        }
Exemplo n.º 6
0
        public void ExecuteGradianTest()
        {
            var exp = new Cos(new Number(1));

            Assert.Equal(Math.Cos(1 * Math.PI / 200), exp.Execute(AngleMeasurement.Gradian));
        }
Exemplo n.º 7
0
        public void ExecuteDegreeTest()
        {
            var exp = new Cos(new Number(1));

            Assert.Equal(Math.Cos(1 * Math.PI / 180), exp.Execute(AngleMeasurement.Degree));
        }