public void CompileAndEvaluate_ModifyInputScript_ElementsOfInputListShouldBeSetToZero() { var processor = new MonoCSharpProcessor(); processor.AddReferenceAssembly(typeof(MyMath.MyMath).Assembly); var parameters = new Dictionary <string, object> { { "v1", new VectorD() } }; var script = processor.Compile(ModifyInputScript, parameters); Assert.IsTrue(script.IsCompiled); Assert.IsTrue(String.IsNullOrEmpty(processor.MessageOutput.ToString())); var v = new VectorD() { 1, 2, 3, 4, 5 };; parameters["v1"] = v; processor.Evaluate(script, parameters); Assert.IsTrue(v.All(e => e == 0)); v = new VectorD() { 1, 2, 3, 4, 5 }; parameters["v1"] = v; processor.Evaluate(parameters); Assert.IsTrue(v.All(e => e == 0)); }
public void DoNotCompile_CallEvaluateByPassingOnlyParameters_ModifyInputScript_ElementsOfInputListShouldBeSetToZero() { var processor = new MonoCSharpProcessor(); processor.AddReferenceAssembly(typeof(MyMath.MyMath).Assembly); var parameters = new Dictionary <string, object> { { "v1", new VectorD() } }; var v = new VectorD() { 1, 2, 3, 4, 5 };; parameters["v1"] = v; processor.Evaluate(ModifyInputScript, parameters); Assert.IsTrue(v.All(e => e == 0)); v = new VectorD() { 1, 2, 3, 4, 5 }; parameters["v1"] = v; processor.Evaluate(parameters); Assert.IsTrue(v.All(e => e == 0)); }
public void DoNotCompile_CallEvaluateByPassingOnlyParameters_CalculateDistanceScript_ExceptionShouldBeThrown() { var processor = new MonoCSharpProcessor(); processor.AddReferenceAssembly(typeof(MyMath.MyMath).Assembly); var parameters = new Dictionary <string, object> { { "v1", new VectorD() }, { "v2", new VectorD() } }; parameters["v1"] = new VectorD() { 1, 2, 3, 4, 5 }; parameters["v2"] = new VectorD() { -1, -2, -3, -4, -5 }; var distance = processor.Evaluate <double>(CalculateDistanceScript, parameters); Assert.AreEqual(5, distance); distance = processor.Evaluate <double>(parameters); }
public void CompileAndEvaluate_CalculateDistanceScript_ResultShouldBeCorrect() { var processor = new MonoCSharpProcessor(); processor.AddReferenceAssembly(typeof(MyMath.MyMath).Assembly); var parameters = new Dictionary <string, object> { { "v1", new VectorD() }, { "v2", new VectorD() } }; var script = processor.Compile(CalculateDistanceScript, parameters); Assert.IsTrue(script.IsCompiled); Assert.IsTrue(String.IsNullOrEmpty(processor.MessageOutput.ToString())); parameters["v1"] = new VectorD() { 1, 2, 3, 4, 5 }; parameters["v2"] = new VectorD() { 1, 2, -3, 4, -5 }; var distance = processor.Evaluate <double>(script, parameters); Assert.AreEqual(2, distance); parameters["v1"] = new VectorD() { 1, 2, 3, 4, 5 }; parameters["v2"] = new VectorD() { -1, -2, -3, -4, -5 }; distance = processor.Evaluate <double>(script, parameters); Assert.AreEqual(5, distance); distance = processor.Evaluate <double>(parameters); Assert.AreEqual(5, distance); }