NewInstance() public method

public NewInstance ( object parameters ) : object
parameters object
return object
Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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"));
        }
Ejemplo n.º 3
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);
        }