public void TanArctan() { var exp = new Tan(new Arctan(new Variable("x"))); var expected = new Variable("x"); SimpleTest(exp, expected); }
public string GetTan(FinService aService) { if (m_vList.Count == 0) { throw new InvalidOperationException("Keine TAN-Nummern in Liste!"); } FinTanProcessParameters aTanProc = aService.TanProcess; FinChallengeInfo aChallengeInfo = aService.ChallengeInfo; // If this is not a 2-step TAN procedure then we always just return the very first // TAN of the list. if ((aTanProc == null) || (aChallengeInfo == null)) { Tan aTan = (Tan)m_vList[0]; return(aTan.TAN); } string sChallenge = aChallengeInfo.Challenge; int nIndex = GetIndexFromChallenge(sChallenge); if (nIndex >= 0) { string sTAN = FindTan(nIndex); if (sTAN != null) { return(sTAN); } } io.Write("Keine TAN für " + sChallenge + "in TAN-Datei gefunden!"); return(null); }
public void CalculationTest(double value, double answer) { var calculator = new Tan(); double actual = calculator.calculate(value); Assert.AreEqual(answer, actual, 0.001); }
public void Calculate() { Tan calculator = new Tan(); double result = calculator.Calculate(0); Assert.AreEqual(0, result, 0.001); }
public void CalculateTest(double value, double expected) { var calculator = new Tan(); var actualResult = calculator.SingleCalculate(value); Assert.AreEqual(expected, actualResult, 0.00001); }
public int LoadTanList(string sFileName) { m_vList.Clear(); using (TextReader aReader = File.OpenText(sFileName)) { for (; ;) { string sTanLine = aReader.ReadLine(); if (sTanLine == null) { break; } sTanLine = sTanLine.Trim(); if (sTanLine == "") { continue; } Tan aTan = new Tan(sTanLine); if (FindTan(aTan.Index) != null) { throw new ApplicationException("Doppelter Index in TAN-Datei!"); } m_vList.Add(aTan); } aReader.Close(); } return(m_vList.Count); }
public void TanTest(double first, double expected) { IOneCalculation calculator = new Tan(); double result = calculator.Calculate(first); Assert.AreEqual(expected, result); }
public void CalculateTest(double argument, double result, double accracy) { var testingFunction = new Tan(); var testResult = testingFunction.Calculate(argument); Assert.AreEqual(result, testResult, accracy); }
public void TestTan(double firstArgument, double output) { var calculator = new Tan(); var testResult = calculator.Calculate(firstArgument); Assert.AreEqual(output, testResult, 0.0000001); }
public void TanArctan() { var exp = new Tan(new Arctan(Variable.X)); var expected = Variable.X; SimpleTest(exp, expected); }
public void TanIntAndDoublesAsInputs() { var function = new Tan(); var input1 = 20; var input2 = 100; var input3 = 1; var input4 = 1.0; var input5 = 1.5; var input6 = 1000; var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext); var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext); var result3 = function.Execute(FunctionsHelper.CreateArgs(input3), this.ParsingContext); var result4 = function.Execute(FunctionsHelper.CreateArgs(input4), this.ParsingContext); var result5 = function.Execute(FunctionsHelper.CreateArgs(input5), this.ParsingContext); var result6 = function.Execute(FunctionsHelper.CreateArgs(input6), this.ParsingContext); Assert.AreEqual(2.237160944, System.Math.Round(result1.ResultNumeric, 9)); Assert.AreEqual(-0.587213915, System.Math.Round(result2.ResultNumeric, 9)); Assert.AreEqual(1.557407725, System.Math.Round(result3.ResultNumeric, 9)); Assert.AreEqual(1.557407725, System.Math.Round(result4.ResultNumeric, 9)); Assert.AreEqual(14.10141995, System.Math.Round(result5.ResultNumeric, 8)); Assert.AreEqual(1.470324156, System.Math.Round(result6.ResultNumeric, 9)); }
public void TanTest(double firstValue, double expected) { var calculator = new Tan(); var actualResult = calculator.Calculate(firstValue); Assert.AreEqual(expected, actualResult); }
public void CloneTest() { var exp = new Tan(new Number(1)); var clone = exp.Clone(); Assert.Equal(exp, clone); }
public void TanHandlesNormal12HourClockInputs() { var function = new Tan(); var input1 = "00:00:00 AM"; var input2 = "00:01:32 AM"; var input3 = "12:00 PM"; var input4 = "12:00 AM"; var input5 = "1:00 PM"; var input6 = "1:10:32 am"; var input7 = "3:42:32 pm"; var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext); var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext); var result3 = function.Execute(FunctionsHelper.CreateArgs(input3), this.ParsingContext); var result4 = function.Execute(FunctionsHelper.CreateArgs(input4), this.ParsingContext); var result5 = function.Execute(FunctionsHelper.CreateArgs(input5), this.ParsingContext); var result6 = function.Execute(FunctionsHelper.CreateArgs(input6), this.ParsingContext); var result7 = function.Execute(FunctionsHelper.CreateArgs(input7), this.ParsingContext); Assert.AreEqual(0, System.Math.Round(result1.ResultNumeric, 8)); Assert.AreEqual(0.001064815, System.Math.Round(result2.ResultNumeric, 9)); Assert.AreEqual(0.54630249, System.Math.Round(result3.ResultNumeric, 9)); Assert.AreEqual(0, System.Math.Round(result4.ResultNumeric, 8)); Assert.AreEqual(0.601697417, System.Math.Round(result5.ResultNumeric, 9)); Assert.AreEqual(0.049020691, System.Math.Round(result6.ResultNumeric, 9)); Assert.AreEqual(0.767388266, System.Math.Round(result7.ResultNumeric, 9)); }
public void TanTestInputsWithDatesThatHaveSlashesInThem() { var function = new Tan(); var input1 = "1/17/2011 2:00 am"; var input2 = "17/01/2011 2:00 AM"; var input3 = "17/Jan/2011 2:00 AM"; var input4 = "17/January/2011 2:00 am"; var input5 = "1/17/2011 2:00:00 am"; var input6 = "17/01/2011 2:00:00 AM"; var input7 = "17/Jan/2011 2:00:00 AM"; var input8 = "17/January/2011 2:00:00 am"; var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext); var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext); var result3 = function.Execute(FunctionsHelper.CreateArgs(input3), this.ParsingContext); var result4 = function.Execute(FunctionsHelper.CreateArgs(input4), this.ParsingContext); var result5 = function.Execute(FunctionsHelper.CreateArgs(input5), this.ParsingContext); var result6 = function.Execute(FunctionsHelper.CreateArgs(input6), this.ParsingContext); var result7 = function.Execute(FunctionsHelper.CreateArgs(input7), this.ParsingContext); var result8 = function.Execute(FunctionsHelper.CreateArgs(input8), this.ParsingContext); Assert.AreEqual(-1.626004608, System.Math.Round(result1.ResultNumeric, 9)); Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result2.Result).Type); Assert.AreEqual(-1.626004608, System.Math.Round(result3.ResultNumeric, 9)); Assert.AreEqual(-1.626004608, System.Math.Round(result4.ResultNumeric, 9)); Assert.AreEqual(-1.626004608, System.Math.Round(result5.ResultNumeric, 9)); Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result6.Result).Type); Assert.AreEqual(-1.626004608, System.Math.Round(result7.ResultNumeric, 9)); Assert.AreEqual(-1.626004608, System.Math.Round(result8.ResultNumeric, 9)); }
public void TanTest(double argument, double result) { var calculator = new Tan(); var testResult = calculator.Calculate(argument); Assert.AreEqual(result, testResult, 0.1); }
public void TanZero() { var exp = new Tan(zero); var expected = new Number(Math.Tan(0)); SimpleTest(exp, expected); }
public void TanTest(double first, double expected) { ISingleCalculator calculate = new Tan(); double result = calculate.Calculate(first); Assert.AreEqual(expected, result, 0.00001); }
public void CalculateTanTestStrong(double firstValue, double expected) { IOneArgumentCalculator calculator = new Tan(); double result = calculator.Calculate(firstValue); Assert.AreEqual(expected, result); }
public void Calculate(double input, double output) { var calculator = new Tan(); var testResult = calculator.Calculate(input); var result = output; Assert.AreEqual(testResult, result, 0.1); }
public void TanWithInvalidArgumentReturnsPoundValue() { var func = new Tan(); var parsingContext = ParsingContext.Create(); var args = FunctionsHelper.CreateArgs(); var result = func.Execute(args, parsingContext); Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type); }
public void Calcpr( double firstElement, double expected) { var calculator = new Tan(); var actualResult = calculator.OneCalculate(firstElement); Assert.AreEqual(expected, actualResult, 0.01); }
public void DoubleFunctionTan() { var sut = new Tan(); var result = sut.Execute(new List <Accumulator> { new Accumulator(Math.PI / 3) }); Assert.AreEqual(Math.Tan(Math.PI / 3), result.ValueAsDouble()); }
public void TanShouldReturnCorrectResult() { var func = new Tan(); var args = FunctionsHelper.CreateArgs(2); var result = func.Execute(args, _parsingContext); var roundedResult = Math.Round((double)result.Result, 9); Assert.AreEqual(-2.185039863d, roundedResult); }
public void ExecuteComplexNumberTest() { var complex = new Complex(3, 2); var exp = new Tan(new ComplexNumber(complex)); var result = (Complex)exp.Execute(); Assert.Equal(Complex.Tan(complex), exp.Execute()); Assert.Equal(-0.0098843750383224935, result.Real, 14); Assert.Equal(0.96538587902213313, result.Imaginary, 14); }
public void TanHandlesMilitaryTimesPast2400() { var function = new Tan(); var input1 = "01:00"; var input2 = "02:00"; var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext); var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext); Assert.AreEqual(0.041690796, System.Math.Round(result1.ResultNumeric, 9)); Assert.AreEqual(0.083526772, System.Math.Round(result2.ResultNumeric, 9)); }
/// <summary> /// Analyzes the specified expression. /// </summary> /// <param name="exp">The expression.</param> /// <returns> /// The result of analysis. /// </returns> public override IExpression Analyze(Tan exp) { if (!Helpers.HasVariable(exp, Variable)) { return(new Number(0)); } var cos = new Cos(exp.Argument.Clone()); var inv = new Pow(cos, new Number(2)); var div = new Div(exp.Argument.Clone().Analyze(this), inv); return(div); }
public void TanHandlesInputDatesAreSeperatedByDashes() { var function = new Tan(); var input1 = "1-17-2017 2:00"; var input2 = "1-17-2017 2:00 am"; var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext); var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext); Assert.AreEqual(3.473770621, System.Math.Round(result1.ResultNumeric, 9)); Assert.AreEqual(3.473770621, System.Math.Round(result2.ResultNumeric, 9)); }
public void TanHandlesTrueOrFalse() { var function = new Tan(); var input1 = true; var input2 = false; var result1 = function.Execute(FunctionsHelper.CreateArgs(input1), this.ParsingContext); var result2 = function.Execute(FunctionsHelper.CreateArgs(input2), this.ParsingContext); Assert.AreEqual(1.557407725, System.Math.Round(result1.ResultNumeric, 9)); Assert.AreEqual(0, System.Math.Round(result2.ResultNumeric, 8)); }
/// <summary> /// Analyzes the specified expression. /// </summary> /// <param name="exp">The expression.</param> /// <returns> /// The result of analysis. /// </returns> public override IExpression Analyze(Sec exp) { if (!Helpers.HasVariable(exp, Variable)) { return(new Number(0)); } var tan = new Tan(exp.Argument.Clone()); var sec = new Sec(exp.Argument.Clone()); var mul1 = new Mul(tan, sec); var mul2 = new Mul(exp.Argument.Clone().Analyze(this), mul1); return(mul2); }
void CreateOperators() { // Only one of each operation Token needs to be created opAdd = new Add(workStack); opSubtract = new Subtract(workStack); opMultiply = new Multiply(workStack); opDivide = new Divide(workStack); opPower = new Power(workStack); opBracket = new Bracket(); opUnaryMinus = new UnaryMinus(workStack); opUnaryPlus = new UnaryPlus(); opSqrt = new Sqrt(workStack); opSin = new Sin(workStack); opCos = new Cos(workStack); opTan = new Tan(workStack); opLog = new Log(workStack); opAsin = new Asin(workStack); opAcos = new Acos(workStack); opAtan = new Atan(workStack); functions = new Dictionary<string, Function> { {"sqr", opSqrt }, {"sin", opSin }, {"cos", opCos }, {"tan", opTan }, {"log", opLog }, {"asin", opAsin }, {"acos", opAcos }, {"atan", opAtan } }; binaryOperators = new Dictionary<char, BinaryOperator> { {'+', opAdd }, {'-', opSubtract }, {'*', opMultiply }, {'/', opDivide }, {'^',opPower } }; }
public int LoadTanList(string sFileName) { m_vList.Clear(); using (TextReader aReader = File.OpenText(sFileName)) { for (; ; ) { string sTanLine = aReader.ReadLine(); if (sTanLine == null) { break; } sTanLine = sTanLine.Trim(); if (sTanLine == "") { continue; } Tan aTan = new Tan(sTanLine); if (FindTan(aTan.Index) != null) { throw new ApplicationException("Doppelter Index in TAN-Datei!"); } m_vList.Add(aTan); } aReader.Close(); } return m_vList.Count; }