public void VarietyOfCalculations() { Assert.AreEqual(25M, decimal.Parse(MathFunctionObj.Power("5", "2"))); Assert.AreEqual(100M, decimal.Parse(MathFunctionObj.Power("10", "2"))); Assert.AreEqual(4096M, decimal.Parse(MathFunctionObj.Power("8", "4"))); Assert.AreEqual(1079986.28684488M, decimal.Parse(MathFunctionObj.Power("25.3", "4.3"))); }
public void ZeroRaisedtoANonZeroPower() { Assert.AreEqual(0M, decimal.Parse(MathFunctionObj.Power("0", "1"))); Assert.AreEqual(0M, decimal.Parse(MathFunctionObj.Power("0", "2"))); Assert.AreEqual(0M, decimal.Parse(MathFunctionObj.Power("0", "0.5"))); Assert.AreEqual(Project1.Functions.MathFunctions.ErrorMessage, MathFunctionObj.Power("0", "-5")); Assert.AreEqual(Project1.Functions.MathFunctions.ErrorMessage, MathFunctionObj.Power("0", "-0.5")); }
public void BadInput() { Assert.AreEqual(Project1.Functions.MathFunctions.ErrorMessage, MathFunctionObj.Power("text", "10")); Assert.AreEqual(Project1.Functions.MathFunctions.ErrorMessage, MathFunctionObj.Power("10", "text")); Assert.AreEqual(Project1.Functions.MathFunctions.ErrorMessage, MathFunctionObj.Power("", "")); Assert.AreEqual(Project1.Functions.MathFunctions.ErrorMessage, MathFunctionObj.Power(null, "")); Assert.AreEqual(Project1.Functions.MathFunctions.ErrorMessage, MathFunctionObj.Power("", null)); Assert.AreEqual(Project1.Functions.MathFunctions.ErrorMessage, MathFunctionObj.Power(null, null)); }
public void NonZeroRaisedToOne() { Assert.AreEqual(1M, decimal.Parse(MathFunctionObj.Power("1", "1"))); Assert.AreEqual(0.5M, decimal.Parse(MathFunctionObj.Power("0.5", "1"))); Assert.AreEqual(-1M, decimal.Parse(MathFunctionObj.Power("-1", "1"))); }