public void testBasic() { ScriptBuilder builder = new ScriptBuilder(); builder.ScriptLanguage = "Groovy"; builder.ScriptText = "print 'foo'"; Script s1 = builder.Build(); Assert.AreEqual("Groovy", s1.ScriptLanguage); Assert.AreEqual("print 'foo'", s1.ScriptText); builder = new ScriptBuilder(); builder.ScriptLanguage = "Groovy"; builder.ScriptText = "print 'foo'"; Script s2 = builder.Build(); Assert.AreEqual(s1, s2); Assert.AreEqual(s1.GetHashCode(), s2.GetHashCode()); }
public void testLanguageNotBlank() { try { ScriptBuilder builder = new ScriptBuilder(); builder.ScriptText = "print 'foo'"; builder.Build(); Assert.Fail(); } catch (ArgumentException) { // OK. } try { ScriptBuilder builder = new ScriptBuilder(); builder.ScriptText = "print 'foo'"; builder.ScriptLanguage = ""; builder.Build(); Assert.Fail(); } catch (ArgumentException) { // OK. } try { ScriptBuilder builder = new ScriptBuilder(); builder.ScriptText = "print 'foo'"; builder.ScriptLanguage = " "; builder.Build(); Assert.Fail(); } catch (ArgumentException) { // OK. } }
public void TestScript() { ScriptBuilder builder = new ScriptBuilder(); builder.ScriptLanguage = "language"; builder.ScriptText = "text"; Script v1 = builder.Build(); Script v2 = (Script)CloneObject(v1); Assert.AreEqual("language", v2.ScriptLanguage); Assert.AreEqual("text", v2.ScriptText); }
public void testTextNotNull() { ScriptBuilder builder = new ScriptBuilder(); try { builder.ScriptLanguage = "Groovy"; builder.Build(); Assert.Fail(); } catch (ArgumentNullException) { // OK. } // The text can be empty. builder = new ScriptBuilder(); builder.ScriptLanguage = "Groovy"; builder.ScriptText = ""; builder.Build(); }