Ejemplo n.º 1
0
        public bool TryDynamicCall(StackContext sctx, PValue[] args, PCall call, string id,
            out PValue result)
        {
            CallExpectation expectation;
            Assert.IsTrue(_expectations.TryGetValue(id, out expectation),
                String.Format("A call to member {0} on object {1} is not expected.", id, Name));

            Assert.AreEqual(expectation.ExpectedCall, call, "Call type (get/set)");
            Assert.AreEqual(expectation.ExpectedArguments.Length, args.Length,
                "Number of arguments do not match. Called with " + args.ToEnumerationString());
            for (var i = 0; i < expectation.ExpectedArguments.Length; i++)
                Assert.AreEqual(expectation.ExpectedArguments[i], args[i],
                    String.Format("Arguments at position {0} don't match", i));

            result = expectation.ReturnValue ?? PType.Null;
            expectation.WasCalled = true;
            return true;
        }