Exemplo n.º 1
0
        public void CreateCustomFunction_NullXamCalculationManager_Expected_ExceptionReturned()
        {
            string        functionName = "TestFunction";
            List <string> arguments    = new List <string> {
                "x", "y"
            };
            List <string> argumentDescriptions = new List <string> {
                "the first argument", "the second argument"
            };
            string description = "My TestFunction";

            IFunction func = MathOpsFactory.CreateFunction(functionName, arguments, argumentDescriptions, description);
            IDev2CalculationManager manager  = null;
            Func <double[], double> function = AddAbs;

            try
            {
                func.CreateCustomFunction(functionName, arguments, argumentDescriptions, description, function, manager);
            }
            catch (NullReferenceException)
            {
                // since this exception is thrown we have our answer.
                Assert.IsTrue(true);
            }
        }
Exemplo n.º 2
0
        public void CreateCustomFunction_NullArgumentDescription_Expected_ExceptionReturned()
        {
            const string  functionName = "TestFunction";
            List <string> arguments    = new List <string> {
                "x", "y"
            };
            const string description = "My TestFunction";

            IFunction func = MathOpsFactory.CreateFunction(functionName, arguments, null, description);
            IDev2CalculationManager manager = new Dev2CalculationManager();

            func.CreateCustomFunction(functionName, arguments, null, description, null, manager);

            Assert.AreNotEqual(null, func.ArgumentDescriptions);
        }
Exemplo n.º 3
0
        public void CreateCustomFunction_NullFunc_Expected_ExceptionReturned()
        {
            string        functionName = "TestFunction";
            List <string> arguments    = new List <string> {
                "x", "y"
            };
            List <string> argumentDescriptions = new List <string> {
                "the first argument", "the second argument"
            };
            string description = "My TestFunction";

            IFunction func = MathOpsFactory.CreateFunction(functionName, arguments, argumentDescriptions, description);
            IDev2CalculationManager manager  = new Dev2CalculationManager();
            Func <double[], double> function = null;

            func.CreateCustomFunction(functionName, arguments, argumentDescriptions, description, function, manager);

            Assert.AreEqual("TestFunction", func.FunctionName);
        }
Exemplo n.º 4
0
        public void CreateCustomFunction_AllValidValues_Expected_CustomFunctionCreatedAndRegisteredWithCalcManager()
        {
            const string  functionName = "TestFunction";
            List <string> arguments    = new List <string> {
                "x", "y"
            };
            List <string> argumentDescriptions = new List <string> {
                "the first argument", "the second argument"
            };
            const string description = "My TestFunction";

            IFunction func = MathOpsFactory.CreateFunction(functionName, arguments, argumentDescriptions, description);
            IDev2CalculationManager manager  = new Dev2CalculationManager();
            Func <double[], double> function = AddAbs;

            func.CreateCustomFunction(functionName, arguments, argumentDescriptions, description, function, manager);
            CalculationValue value = manager.CalculateFormula("TestFunction(1)");

            Assert.AreEqual(123123423423, value.ToDouble());
        }