public void TryGetVariableGeneric_VariableExists_ReturnsCorrectValue(ScriptEngineBase engine) { using (engine) { int x; engine.SetVariable("x", 1); engine.TryGetVariable<int>("x", out x); Assert.Equal<int>(1, x); } }
public void TryGetVariableGeneric_VariableExists_ReturnsTrue(ScriptEngineBase engine) { using (engine) { int x; engine.SetVariable("x", 1); Assert.True(engine.TryGetVariable<int>("x", out x)); } }
public void SetVariable_SetsVariable(ScriptEngineBase engine) { using (engine) { engine.SetVariable("x", 1); Assert.Equal<int>(1, engine.GetVariable("x")); } }
public void TryGetVariableDynamic_VariableExists_ReturnsTrue(ScriptEngineBase engine) { using (engine) { dynamic x; engine.SetVariable("x", 1); Assert.True(engine.TryGetVariable("x", out x)); } }
public void ScriptDoublesVariableValue_ReturnsCorrectValue(ScriptEngineBase engine, string script) { using (engine) { engine.SetVariable("x", 1.0); engine.SetScript(script); engine.Execute(); Assert.Equal<double>(2, engine.GetVariable("x")); } }
public void SetVariable_NullName_Throws(ScriptEngineBase engine) { using (engine) { Assert.Throws<ArgumentNullException>(() => engine.SetVariable(null, 0)); } }
public void RemoveVariable_RemovesVariable(ScriptEngineBase engine) { using (engine) { engine.SetVariable("x", 1); engine.RemoveVariable("x"); Assert.False(engine.ContainsVariable("x")); } }
public void GetVariableGeneric_VariableWasSet_ReturnsVariable(ScriptEngineBase engine) { using (engine) { engine.SetVariable("x", 1); Assert.Equal<int>(1, engine.GetVariable<int>("x")); } }
public void GetItems_ReturnsVariables(ScriptEngineBase engine) { using (engine) { engine.SetVariable("x", 1); Assert.True(engine.GetItems().Select(item => new KeyValuePair<string, int>(item.Key, item.Value)) .SequenceEqual(new KeyValuePair<string, int>[] { new KeyValuePair<string, int>("x", 1) }), "GetItems returned unexpected sequence."); } }
public void ContainsVariable_VariableExists_ReturnsTrue(ScriptEngineBase engine) { using (engine) { engine.SetVariable("x", 1); Assert.True(engine.ContainsVariable("x")); } }
public void ClearScope_RemovesVariables(ScriptEngineBase engine) { using (engine) { engine.SetVariable("x", 1); engine.ClearScope(); Assert.False(engine.ContainsVariable("x")); } }