public void TestFactorial() { //Arrange VariableNode variableNode = new VariableNode(); FactorialFunction factorialNode = new FactorialFunction(variableNode); //Act double result1 = factorialNode.Calculate(0); double result2 = factorialNode.Calculate(1); double result3 = factorialNode.Calculate(2); double result4 = factorialNode.Calculate(4); //Assert Assert.AreEqual(1, result1); Assert.AreEqual(1, result2); Assert.AreEqual(2, result3); Assert.AreEqual(24, result4); }
public void SuccessfullyReturnValueGivenAPositiveDouble() { var function = new FactorialFunction(); var inputs = function.GetInputs(); inputs[0].Value = 5.5; var result = function.Calculate(inputs); Assert.NotNull(result); Assert.Collection(result, i => { Assert.Equal(typeof(double), i.Value.GetType()); Assert.Equal(287.88527781504507, TypeConverter.ToObject <double>(i.Value)); }); }
public void SuccessfullyReturnValueGivenAPositiveInteger() { var function = new FactorialFunction(); var inputs = function.GetInputs(); Assert.Single(inputs); inputs[0].Value = 5; var result = function.Calculate(inputs); Assert.NotNull(result); Assert.Collection(result, i => { Assert.Equal(typeof(double), i.Value.GetType()); Assert.Equal(120, TypeConverter.ToObject <int>(i.Value)); }); }