public void BadInput() { Assert.AreEqual(Project1.Functions.MathFunctions.ErrorMessage, MathFunctionObj.Multiply("text", "10")); Assert.AreEqual(Project1.Functions.MathFunctions.ErrorMessage, MathFunctionObj.Multiply("10", "text")); Assert.AreEqual(Project1.Functions.MathFunctions.ErrorMessage, MathFunctionObj.Multiply("", "")); Assert.AreEqual(Project1.Functions.MathFunctions.ErrorMessage, MathFunctionObj.Multiply(null, "")); Assert.AreEqual(Project1.Functions.MathFunctions.ErrorMessage, MathFunctionObj.Multiply("", null)); Assert.AreEqual(Project1.Functions.MathFunctions.ErrorMessage, MathFunctionObj.Multiply(null, null)); }
public void IntegerMultiplication() { for (int i = 0; i <= 10; i++) { for (int j = 0; j <= 10; j++) { var result = System.Convert.ToDecimal(i * j); Assert.AreEqual(result, decimal.Parse(MathFunctionObj.Multiply(i.ToString(), j.ToString()))); Assert.AreEqual(result, decimal.Parse(MathFunctionObj.Multiply(j.ToString(), i.ToString()))); Assert.AreEqual(result, decimal.Parse(MathFunctionObj.Multiply(" " + i.ToString(), j.ToString()))); Assert.AreEqual(result, decimal.Parse(MathFunctionObj.Multiply(" " + i.ToString(), " " + j.ToString()))); } } }
public void NonIntegerMultiplication() { foreach (double d1 in new[] { 3.5, 2.5, 7.12, 123.9 }) { foreach (double d2 in new[] { 1.2, 10.23, -23.1, 0.223, 0, 10.1 }) { var result = System.Convert.ToDecimal(d1 * d2); Assert.AreEqual(result, decimal.Parse(MathFunctionObj.Multiply(d1.ToString(), d2.ToString()))); Assert.AreEqual(result, decimal.Parse(MathFunctionObj.Multiply(d2.ToString(), d1.ToString()))); Assert.AreEqual(result, decimal.Parse(MathFunctionObj.Multiply(d2.ToString() + " ", d1.ToString()))); Assert.AreEqual(result, decimal.Parse(MathFunctionObj.Multiply(d2.ToString(), " " + d1.ToString()))); } } }