Ejemplo n.º 1
0
        public void NegativeComplexNumberExecuteTest()
        {
            var complex = new Complex(-25, 13);
            var exp     = new Sqrt(new ComplexNumber(complex));

            Assert.Equal(Complex.Sqrt(complex), exp.Execute());
        }
Ejemplo n.º 2
0
        public void ComplexExecuteTest()
        {
            var complex = new Complex(5, 3);
            var exp     = new Sqrt(new ComplexNumber(complex));

            Assert.Equal(Complex.Sqrt(complex), exp.Execute());
        }
Ejemplo n.º 3
0
        public void SqrtFunctionWithPositiveIntegerInStringReturnsCorrectResult()
        {
            var function  = new Sqrt();
            var arguments = FunctionsHelper.CreateArgs("4");
            var result    = function.Execute(arguments, this.ParsingContext);

            Assert.AreEqual(2d, result.Result);
        }
Ejemplo n.º 4
0
        public void SqrtFunctionWithNegativeDoubleReturnsPoundNum()
        {
            var function  = new Sqrt();
            var arguments = FunctionsHelper.CreateArgs(-1.5);
            var result    = function.Execute(arguments, this.ParsingContext);

            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)result.Result).Type);
        }
Ejemplo n.º 5
0
        public void SqrtFunctionWithZeroReturnsCorrectResult()
        {
            var function  = new Sqrt();
            var arguments = FunctionsHelper.CreateArgs(0);
            var result    = function.Execute(arguments, this.ParsingContext);

            Assert.AreEqual(0d, result.Result);
        }
Ejemplo n.º 6
0
        public void SqrtFunctionWithTooFewArgumentsReturnsPoundValue()
        {
            var function  = new Sqrt();
            var arguments = FunctionsHelper.CreateArgs();
            var result    = function.Execute(arguments, this.ParsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type);
        }
Ejemplo n.º 7
0
        public void SqrtWithInvalidArgumentReturnsPoundValue()
        {
            var func           = new Sqrt();
            var parsingContext = ParsingContext.Create();
            var args           = FunctionsHelper.CreateArgs();
            var result         = func.Execute(args, parsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type);
        }
Ejemplo n.º 8
0
        public void SqrtFunctionWithErrorValuesAsInputReturnsTheInputErrorValue()
        {
            var function      = new Sqrt();
            var argumentNA    = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.NA));
            var argumentNAME  = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.Name));
            var argumentVALUE = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.Value));
            var argumentNUM   = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.Num));
            var argumentDIV0  = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.Div0));
            var argumentREF   = FunctionsHelper.CreateArgs(ExcelErrorValue.Create(eErrorType.Ref));
            var resultNA      = function.Execute(argumentNA, this.ParsingContext);
            var resultNAME    = function.Execute(argumentNAME, this.ParsingContext);
            var resultVALUE   = function.Execute(argumentVALUE, this.ParsingContext);
            var resultNUM     = function.Execute(argumentNUM, this.ParsingContext);
            var resultDIV0    = function.Execute(argumentDIV0, this.ParsingContext);
            var resultREF     = function.Execute(argumentREF, this.ParsingContext);

            Assert.AreEqual(eErrorType.NA, ((ExcelErrorValue)resultNA.Result).Type);
            Assert.AreEqual(eErrorType.Name, ((ExcelErrorValue)resultNAME.Result).Type);
            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)resultVALUE.Result).Type);
            Assert.AreEqual(eErrorType.Num, ((ExcelErrorValue)resultNUM.Result).Type);
            Assert.AreEqual(eErrorType.Div0, ((ExcelErrorValue)resultDIV0.Result).Type);
            Assert.AreEqual(eErrorType.Ref, ((ExcelErrorValue)resultREF.Result).Type);
        }
Ejemplo n.º 9
0
        public void NegativeNumberExecuteTest2()
        {
            var exp = new Sqrt(new Number(-1));

            Assert.Equal(new Complex(0, 1), exp.Execute());
        }
Ejemplo n.º 10
0
        public void ExecuteTest1()
        {
            var exp = new Sqrt(new Number(4));

            Assert.Equal(Math.Sqrt(4), exp.Execute());
        }