public void FailWhenGivenLessThanZero()
        {
            var function = new NaturalLogarithmFunction();

            var inputs = function.GetInputs();

            Assert.Throws <ArgumentException>(() =>
            {
                inputs[0].Value = -1;
            });
        }
Example #2
0
        public void SuccessfullySetFunctionInfo()
        {
            var function = new NaturalLogarithmFunction();

            Assert.NotNull(function.FunctionInfo);
            Assert.Equal("Natural Logarithm", function.FunctionInfo.Name);
            Assert.Equal(new Version("1.0.0"), function.FunctionInfo.Version);
            Assert.Equal("Find the natural logarithm of a number.", function.FunctionInfo.Description);
            Assert.Collection(function.FunctionInfo.Tags,
                              i => Assert.Equal("algebra", i),
                              i => Assert.Equal("natural", i),
                              i => Assert.Equal("logarithm", i),
                              i => Assert.Equal("e", i));
        }
        public void SuccessfullyReturnWithDefaultValues()
        {
            var function = new NaturalLogarithmFunction();

            var inputs = function.GetInputs();

            Assert.Single(inputs);

            var result = function.Calculate(inputs);

            Assert.NotNull(result);
            Assert.Collection(result,
                              i =>
            {
                Assert.Equal(typeof(double), i.Value.GetType());
                Assert.Equal(0, TypeConverter.ToObject <int>(i.Value));
            });
        }
        public void SuccessfullyReturnGivenPositiveValue()
        {
            var function = new NaturalLogarithmFunction();

            var inputs = function.GetInputs();

            Assert.Single(inputs);

            inputs[0].Value = 27.3;

            var result = function.Calculate(inputs);

            Assert.NotNull(result);
            Assert.Collection(result,
                              i =>
            {
                Assert.Equal(typeof(double), i.Value.GetType());
                Assert.Equal(3.3068867021909143, TypeConverter.ToObject <double>(i.Value));
            });
        }
Example #5
0
 /// <summary>
 /// Calculates the natural logarithm for all elements.
 /// </summary>
 /// <returns></returns>
 public InstantVector NaturalLogarithm()
 {
     return(AddAction(NaturalLogarithmFunction.Create()));
 }