コード例 #1
0
        public void SuccessfullySetFunctionInfo()
        {
            var function = new LogarithmFunction();

            Assert.NotNull(function.FunctionInfo);
            Assert.Equal("Logarithm", function.FunctionInfo.Name);
            Assert.Equal("Find the logarithm of a number.", function.FunctionInfo.Description);
            Assert.Collection(function.FunctionInfo.Tags,
                              i => Assert.Equal("algebra", i),
                              i => Assert.Equal("logarithm", i));
        }
コード例 #2
0
ファイル: EqualityTests.cs プロジェクト: pedrodbs/Genetica
        public void EqualsButDiffRefsTestProgram()
        {
            var const1   = new Constant(0);
            var const2   = new Constant(1);
            var const3   = new Constant(3);
            var addition = new AdditionFunction(const1, const3);
            var subtr    = new SubtractionFunction(const2, addition);
            var log1     = new LogarithmFunction(subtr, const1);
            var log2     = new LogarithmFunction(subtr, const1);

            Console.WriteLine($"{log1}, {log2}");
            Assert.AreEqual(log1, log2, $"{log1} should be equal to {log2}.");
            Assert.AreNotSame(log1, log2, $"{log1} should not be the same as {log2}.");
        }
コード例 #3
0
        public void TestLogarithm()
        {
            //Arrange
            VariableNode      variableNode  = new VariableNode();
            LogarithmFunction logarithmNode = new LogarithmFunction(variableNode);

            //Act
            double result1 = logarithmNode.Calculate(1);
            double result2 = logarithmNode.Calculate(2);
            double result4 = logarithmNode.Calculate(4);

            //Assert
            Assert.AreEqual(0, result1);
            Assert.AreEqual(0.6931, Math.Round(result2, 4));
            Assert.AreEqual(1.3863, Math.Round(result4, 4));
        }
コード例 #4
0
        public void SuccessfullyCalculateALogarithmWithOnlyLogarithmSpecified()
        {
            var function = new LogarithmFunction();

            var inputs = function.GetInputs();

            Assert.Equal(2, inputs.Length);

            inputs[0].Value = 8;

            var result = function.Calculate(inputs);

            Assert.Collection(result,
                              i =>
            {
                Assert.Equal(typeof(double), i.Value.GetType());
                Assert.Equal(Math.Log(8, 10), TypeConverter.ToObject <double>(i.Value));
            });
        }