protected virtual void RunButton_Click(object sender, EventArgs e) { var language = new LanguagesFactory().Create(PythonRadioButton.Text); var sharepointContext = new SharePointContext(SPContext.Current, language, new Console()); language.Execute(ScriptTextBox.Text); ResultLabel.Text = sharepointContext.Message; }
private void repl_webpart_should_fire_python_scripts() { SPWeb web = Isolate.Fake.Instance<SPWeb>(); SPContext context = Isolate.Fake.Instance<SPContext>(); Isolate.WhenCalled(() => web.Title).WillReturn("Fake Title"); Isolate.WhenCalled(() => context.Web).WillReturn(web); var language = new LanguagesFactory().Create("Python"); var sharepointContext = new SharePointContext(context, language, new Console()); language.Execute("Console.Write(__web__.Title)"); Assert.AreEqual(sharepointContext.Message, web.Title); }