public void AddBasicObject() { BasicMathObject bmo = new BasicMathObject() { ExpectedA = 1, ExpectedB = 5 }; scriptEngine.AddObject("Math", bmo); scriptEngine.AddCode("Math.Add 1, 5"); scriptEngine.Start(); }
public void AddBasicGlobalMemberObject() { BasicMathObject bmo = new BasicMathObject() { ExpectedA = 2, ExpectedB = 7 }; scriptEngine.AddGlobalMemberObject("Math", bmo); scriptEngine.Start(); // No Math alias used. scriptEngine.AddCode("Add 2, 7"); dynamic script = scriptEngine.GetScriptHandle(); }
public void CallObjectWithNoAlias() { BasicMathObject bmo = new BasicMathObject() { ExpectedA = 1, ExpectedB = 5 }; scriptEngine.AddObject("Math", bmo); scriptEngine.AddCode("Add 1, 5"); scriptEngine.Start(); bmo.ExpectedA = 23; bmo.ExpectedB = 57; }
public void AddObjectsWithSameName() { BasicMathObject bmo = new BasicMathObject() { ExpectedA = 2, ExpectedB = 7 }; scriptEngine.AddObject("Math", bmo); try { scriptEngine.AddObject("Math", bmo); Assert.Fail("Expected ArgumentException"); } catch (ArgumentException) { } }