Пример #1
0
        public ActionResult Update(String id, FormCollection formCollection)
        {
            switch (formCollection["Type"].ToString().Trim().ToLower())
            {
            case "git":
                Dictionary <String, String> gitAuthentication = new Dictionary <String, String>();
                gitAuthentication.Add("Location", formCollection["Location"]);
                gitAuthentication.Add("Username", formCollection["Username"]);
                gitAuthentication.Add("Password", formCollection["Password"]);

                _scriptService.UpdateScript(id, formCollection["GhostRunnerScript.Name"], formCollection["GhostRunnerScript.Description"], JsonConvert.SerializeObject(gitAuthentication, new KeyValuePairConverter()));
                break;

            default:
                _scriptService.UpdateScript(id, formCollection["GhostRunnerScript.Name"], formCollection["GhostRunnerScript.Description"], formCollection["Content"]);
                break;
            }

            Script script = _scriptService.GetScript(id);

            return(RedirectToAction("Index/" + script.Project.ExternalId, "Scripts", new { view = "scripts" }));
        }
        public void UpdateScript()
        {
            Script script1 = _scriptService.GetScript("5a768553-052e-47ee-bf48-68f8aaf9cd05");

            Assert.IsNotNull(script1);
            Assert.AreEqual("Test Script 1", script1.Name);
            Assert.AreEqual("Script used for testing", script1.Description);
            Assert.AreEqual("Test script with [parameter1]", script1.Content);

            Boolean updateSuccessful = _scriptService.UpdateScript("5a768553-052e-47ee-bf48-68f8aaf9cd05", "new name", "new description", "new content");

            Assert.IsTrue(updateSuccessful);

            Script updatedScript1 = _scriptService.GetScript("5a768553-052e-47ee-bf48-68f8aaf9cd05");

            Assert.IsNotNull(updatedScript1);
            Assert.AreEqual("new name", updatedScript1.Name);
            Assert.AreEqual("new description", updatedScript1.Description);
            Assert.AreEqual("new content", updatedScript1.Content);

            Boolean updateFailing = _scriptService.UpdateScript("99", "new name", "new description", "new content");

            Assert.IsFalse(updateFailing);
        }