コード例 #1
0
        public void RuntimeEvaluator_CanChangeObjectInstance_PropertiesAndFields()
        {
            this._evaluator.AddAssemblyReference(Assembly.GetExecutingAssembly().FullName);

            var dummy = new DummyTestClass();

            this._evaluator.AddInstancedObject(dummy, "dummy");

            Assert.DoesNotThrow(() =>
            {
                this._evaluator.Evaluate("dummy.DummyStringProperty = \"Forty Two\"");
                this._evaluator.Evaluate("dummy.DummyIntProperty = 42");
                this._evaluator.Evaluate("dummy.DummyStringField = \"42\"");
                this._evaluator.Evaluate("dummy.DummyIntField = 101010");
            });

            Assert.That(dummy.DummyStringProperty, Is.EqualTo("Forty Two"));
            Assert.That(dummy.DummyIntProperty, Is.EqualTo(42));
            Assert.That(dummy.DummyStringField, Is.EqualTo("42"));
            Assert.That(dummy.DummyIntField, Is.EqualTo(101010));

            Assert.That(this._evaluator.Evaluate("dummy.DummyStringProperty"), Is.EqualTo("Forty Two"));
            Assert.That(this._evaluator.Evaluate("dummy.DummyIntProperty"), Is.EqualTo("42"));
            Assert.That(this._evaluator.Evaluate("dummy.DummyStringField"), Is.EqualTo("42"));
            Assert.That(this._evaluator.Evaluate("dummy.DummyIntField"), Is.EqualTo("101010"));
        }
コード例 #2
0
        public void RuntimeEvaluator_CanCreateObjectInstance()
        {
            this._evaluator.AddAssemblyReference(Assembly.GetExecutingAssembly().FullName);

            var dummy = new DummyTestClass();

            Assert.DoesNotThrow(() => { this._evaluator.AddInstancedObject(dummy, "dummy"); });
        }
コード例 #3
0
        public void RuntimeEvaluator_CanAccessPrivateFields()
        {
            Assert.Pass("This test does not pass yet. This pass is only a placeholder.");
            this._evaluator.AddAssemblyReference(Assembly.GetExecutingAssembly().FullName);

            var dummy = new DummyTestClass();

            this._evaluator.AddInstancedObject(dummy, "dummy");

            Assert.That(this._evaluator.Evaluate("dummy._privateIntField"), Is.EqualTo("42"));
        }
コード例 #4
0
        public void RuntimeEvaluator_CanCallInstanceMethods()
        {
            this._evaluator.AddAssemblyReference(Assembly.GetExecutingAssembly().FullName);

            var dummy = new DummyTestClass();

            this._evaluator.AddInstancedObject(dummy, "dummy");

            Assert.That(this._evaluator.Evaluate("dummy.DummyStringMethod(\"Forty Two\")"), Is.EqualTo("Forty Two"));
            Assert.That(this._evaluator.Evaluate("dummy.DummyIntMethod(42)"), Is.EqualTo("42"));
        }
コード例 #5
0
        public void RuntimeEvaluator_CanAccessObjectInstance()
        {
            this._evaluator.AddAssemblyReference(Assembly.GetExecutingAssembly().FullName);

            var dummy = new DummyTestClass();

            this._evaluator.AddInstancedObject(dummy, "dummy");
            var output = this._evaluator.Evaluate("dummy;");

            Assert.That(output, Is.EqualTo("BrandoSoft.CSharp.Evaluator.Test.DummyTestClass"));
        }