Esempio n. 1
0
        public void HasPrototype()
        {
            StringFunction function = new StringFunction(null);

            var result = function.GetValue("prototype");

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(StringObject));
        }
Esempio n. 2
0
        public void InvokeWithIntegerArgument()
        {
            StringFunction function = new StringFunction(null);

            var result = function.Invoke(null, null, new object[] { 42 });

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(string));
            Assert.AreEqual("42", result);
        }
Esempio n. 3
0
        public void CreateEmptyInstance()
        {
            StringFunction function = new StringFunction(null);

            var result = function.NewInstance(null);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(DynamicObject));

            var dynobj = (DynamicObject)result;

            Assert.AreEqual(0, dynobj.GetNames().Count);
        }
Esempio n. 4
0
        public void CreateInstanceFromString()
        {
            StringFunction function = new StringFunction(null);

            var result = function.NewInstance(new object[] { "foo" });

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(DynamicObject));

            var dynobj = (DynamicObject)result;

            Assert.AreEqual(3, dynobj.GetNames().Count);
            Assert.AreEqual("f", dynobj.GetValue("0"));
            Assert.AreEqual("o", dynobj.GetValue("1"));
            Assert.AreEqual("o", dynobj.GetValue("2"));
        }
Esempio n. 5
0
        public void NewInstanceToString()
        {
            StringFunction function = new StringFunction(null);

            var result = function.NewInstance(new object[] { "foo" });

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(DynamicObject));

            var dynobj = (DynamicObject)result;

            result = dynobj.Invoke("toString", null);

            Assert.IsNotNull(result);
            Assert.AreEqual("foo", result);
        }
Esempio n. 6
0
        public void InvokeWithoutArguments()
        {
            StringFunction function = new StringFunction(null);

            var result = function.Invoke(null, null, null);

            Assert.IsNotNull(result);
            Assert.AreEqual(string.Empty, result);
        }