public void NegativeComplexNumberExecuteTest() { var complex = new Complex(-25, 13); var exp = new Sqrt(new ComplexNumber(complex)); Assert.Equal(Complex.Sqrt(complex), exp.Execute()); }
public void ComplexExecuteTest() { var complex = new Complex(5, 3); var exp = new Sqrt(new ComplexNumber(complex)); Assert.Equal(Complex.Sqrt(complex), exp.Execute()); }
public void SqrtFunctionWithPositiveIntegerInStringReturnsCorrectResult() { var function = new Sqrt(); var arguments = FunctionsHelper.CreateArgs("4"); var result = function.Execute(arguments, this.ParsingContext); Assert.AreEqual(2d, result.Result); }
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); }
public void SqrtFunctionWithZeroReturnsCorrectResult() { var function = new Sqrt(); var arguments = FunctionsHelper.CreateArgs(0); var result = function.Execute(arguments, this.ParsingContext); Assert.AreEqual(0d, result.Result); }
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); }
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); }
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); }
public void NegativeNumberExecuteTest2() { var exp = new Sqrt(new Number(-1)); Assert.Equal(new Complex(0, 1), exp.Execute()); }
public void ExecuteTest1() { var exp = new Sqrt(new Number(4)); Assert.Equal(Math.Sqrt(4), exp.Execute()); }