public void Calculate_SingleValue_AllTheSame()
        {
            var curve = new ParamCurve(100);
            var act   = curve.Calculate(3);
            var exp   = new int[] { 100, 100, 100 };

            CollectionAssert.AreEqual(exp, act);
        }
        public void Calculate_Squared_Parabool()
        {
            var curve = new ParamCurve(1, 2, 0);
            var act   = curve.Calculate(6);
            var exp   = new int[] { 0, 1, 4, 9, 16, 25 };

            CollectionAssert.AreEqual(exp, act);
        }
        public void Calculate_HalfPower3Minus10_Parabool()
        {
            var curve = new ParamCurve(0.5, 3, -10);
            var act   = curve.Calculate(4);
            var exp   = new int[] { -10, -10, -6, 4 };

            CollectionAssert.AreEqual(exp, act);
        }
        private ParamCurve Randomize(ParamCurve value)
        {
            var a     = Randomize(value.A);
            var power = Randomize(value.Power);
            var delta = Randomize(value.Delta);

            return(new ParamCurve(a, power, delta));
        }
        public void Calculate_0To5Factor1Power1_StraightLine()
        {
            var curve = new ParamCurve(1, 1, 0);
            var act   = curve.Calculate(6);
            var exp   = new int[] { 0, 1, 2, 3, 4, 5 };

            CollectionAssert.AreEqual(exp, act);
        }
		public void Calculate_SingleValue_AllTheSame()
		{
			var curve = new ParamCurve(100);
			var act = curve.Calculate(3);
			var exp = new int[] { 100, 100, 100 };

			CollectionAssert.AreEqual(exp, act);
		}
		public void Calculate_HalfPower3Minus10_Parabool()
		{
			var curve = new ParamCurve(0.5, 3, -10);
			var act = curve.Calculate(4);
			var exp = new int[] { -10, -10, -6, 4 };

			CollectionAssert.AreEqual(exp, act);
		}
		public void Calculate_Squared_Parabool()
		{
			var curve = new ParamCurve(1, 2, 0);
			var act = curve.Calculate(6);
			var exp = new int[] { 0, 1, 4, 9, 16, 25 };

			CollectionAssert.AreEqual(exp, act);
		}
		public void Calculate_0To5Factor1Power1_StraightLine()
		{
			var curve = new ParamCurve(1, 1, 0);
			var act = curve.Calculate(6);
			var exp = new int[] { 0, 1, 2, 3, 4, 5 };

			CollectionAssert.AreEqual(exp, act);
		}
예제 #10
0
        public static string ParametersToString(EvaluatorParameters pars)
        {
            var writer = new StringBuilder();

            writer.AppendLine("{");
            foreach (var prop in Props)
            {
                if (prop.PropertyType == typeof(int))
                {
                    int val = (int)prop.GetValue(pars);
                    writer.AppendFormat("{0} = {1},", prop.Name, val);
                    writer.AppendLine();
                }
                else if (prop.PropertyType == typeof(bool))
                {
                    bool val = (bool)prop.GetValue(pars);
                    writer.AppendFormat("{0} = {1},", prop.Name, val.ToString().ToLowerInvariant());
                    writer.AppendLine();
                }
                else if (prop.PropertyType == typeof(int[]))
                {
                    int[] vals = (int[])prop.GetValue(pars);
                    writer.AppendFormat("{0} = new [] {{ {1} }},", prop.Name, String.Join(",", vals));
                    writer.AppendLine();
                }
                else if (prop.PropertyType == typeof(ParamCurve))
                {
                    ParamCurve val = (ParamCurve)prop.GetValue(pars);
                    writer.AppendFormat("{0} = {1},", prop.Name, val);
                    writer.AppendLine();
                }
            }
            writer.AppendLine("};");

            return(writer.ToString());
        }