コード例 #1
0
        public void TestVarArgs()
        {
            int[] callArray = new int[6];

            Action <int> onCall = i =>
            {
                callArray[i - 1]++;
            };

            RunTest(context =>
            {
                var vaTest = new VarArgTest(onCall);
                context.SetValue("vaTest", vaTest);
                context.SetValue("t", new CallCount());
                context.RunScript(string.Empty, "vaTest.Accept('hello', 13);");
                context.RunScript(string.Empty, "vaTest.Accept('test', 13, 'a', 'b', 'c', 'd', 'e', 'f', 32.5, t);");
                context.RunScript(string.Empty, "vaTest.Accept('test', 'me again');");
                context.SetValue("foo", new FooObj {
                    Name = "Bill"
                });
                context.RunScript(string.Empty, "vaTest.Accept(foo, 1, 2, 3);");
                context.RunScript(string.Empty, "vaTest.Accept();");
                Assert.Throws <Exception>(() =>
                {
                    context.RunScript(string.Empty, "vaTest.Accept('test', 'me', 1, 2, 3);");
                });
                context.SetValue("foo", new FooObj {
                    Name = "Bill"
                });
                context.RunScript(string.Empty, "vaTest.Accept(foo, 1, 2, 3);");

                context.RunScript(string.Empty, "vaTest.Accept(55, 'hi');");
                context.RunScript(string.Empty, "vaTest.Accept(true, 'hiyo', 15, 'what', 'up', 'brother?');");
                context.RunScript(string.Empty, "vaTest.Accept(23, 'hiyo', 15, 'what', 'up', 'brother?', foo);");
                Assert.Throws <Exception>(() =>
                {
                    context.RunScript(string.Empty, "vaTest.Accept(false, 'hiyo', 15, 'what', 'up', 'brother?', foo);");
                });
                context.RunScript(string.Empty, "vaTest.Accept(5, [ 1, 2, 3, 4, 5 ], 'whee', 'whee', 'what');");
            });

            Asserter.AreEqual(callArray, new int[] { 1, 2, 2, 3, 1, 1 });
        }
コード例 #2
0
 public void SingleStringArrayParameter(string[] h)
 {
     Console.WriteLine("SingleStringArrayParameter(string[] h)");
     TotalCalls++;
     Asserter.AreEqual(h, HH);
 }
コード例 #3
0
 public void SingleBoolArrayParameter(bool[] g)
 {
     Console.WriteLine("SingleBoolArrayParameter(bool[] g)");
     TotalCalls++;
     Asserter.AreEqual(g, GG);
 }
コード例 #4
0
 public void SingleDecimalArrayParameter(decimal[] f)
 {
     Console.WriteLine("SingleDecimalArrayParameter(decimal[] f)");
     TotalCalls++;
     Asserter.AreEqual(f, FF);
 }
コード例 #5
0
 public void SingleDoubleArrayParameter(double[] e)
 {
     Console.WriteLine("SingleDoubleArrayParameter(double[] e)");
     TotalCalls++;
     Asserter.AreEqual(e, EE);
 }
コード例 #6
0
 public void SingleFloatArrayParameter(float[] d)
 {
     Console.WriteLine("SingleFloatArrayParameter(float[] d)");
     TotalCalls++;
     Asserter.AreEqual(d, DD);
 }
コード例 #7
0
 public void SingleIntArrayParameter(int[] c)
 {
     Console.WriteLine("SingleIntArrayParameter(int[] c)");
     TotalCalls++;
     Asserter.AreEqual(c, CC);
 }
コード例 #8
0
 public void SingleShortArrayParameter(short[] b)
 {
     Console.WriteLine("SingleShortArrayParameter(short[] b)");
     TotalCalls++;
     Asserter.AreEqual(b, BB);
 }
コード例 #9
0
 public void SingleByteArrayParameter(byte[] a)
 {
     Console.WriteLine("SingleByteArrayParameter(byte[] a)");
     TotalCalls++;
     Asserter.AreEqual(a, AA);
 }