Ejemplo n.º 1
0
        public void ValueFunction()
        {
            CoopForm cf = new CoopForm();

            int[]  materials = new int[5];
            double loc       = 0;
            string function  = cf.getRandomFunction(5);

            materials[0] = 12;
            materials[1] = 10;
            materials[2] = 11;
            materials[3] = 8;
            materials[4] = 14;

            string[] func = function.Split('+');

            for (int i = 0; i < 5; i++)
            {
                int v = Convert.ToInt32(func[i].Substring(0, 1));
                loc += v * materials[i];
            }

            ValueFunction vf  = new ValueFunction(function);
            double        res = vf.getValue(materials);

            Assert.AreEqual(res, loc);
        }
Ejemplo n.º 2
0
        public void GetRandomFunction()
        {
            int      m   = 5;
            CoopForm cf  = new CoopForm();
            string   res = cf.getRandomFunction(m);

            Assert.IsTrue(res.Length == (5 * m - 1)); // <number>*X<number2>+<number>*X<number2>+
        }