コード例 #1
0
ファイル: TestDataService.cs プロジェクト: Gnail-nehc/Black
 public bool AddTestData(TestData testData, out string log)
 {
     Guard.ArgumentNotNull(testData, "testDataObject");
     int pid = (this.CurrentProjectId > 0) ? this.CurrentProjectId : 1;
     testData.ProjectId = pid;
     return this.TestDataRepository.AddTestData(testData, out log);
 }
コード例 #2
0
 public ActionResult Create(TestData instance)
 {
     ActionResult ar = VerifyIfProjectSelected("PRJNAME");
     if (null != ar) return ar;
     ViewBag.Title = "Create Test Data";
     string requestKey = Request.Form.Keys[Request.Form.Keys.Count - 1] as string;
     if (requestKey.Contains(".")) requestKey = requestKey.Substring(0, requestKey.IndexOf("."));
     if (requestKey == "save")
     {
         string log = "";
         this.TestDataService.CurrentProjectId = (int)Session["PID"];
         if (null == Session["TestCaseBound"])
         {
             if (ModelState.IsValid)
             {
                 bool isSuccess = this.TestDataService.AddTestData(instance, out log);
                 if (isSuccess)
                 {
                     Session["Log_t"] = null;
                     Session["HasQueried_t"] = null;
                     return RedirectToAction("Index");
                 }
                 ViewBag.Log = log;
             }
         }
         else
         {
             instance.TestCaseId = Session["TestCaseBound"].ToString();
             bool isSuccess = this.TestDataService.AddTestData(instance, out log);
             if (isSuccess)
             {
                 Session["Log_t"] = null;
                 return RedirectToAction("Index");
             }
             ViewBag.Log = log;
         }
         return View("Create", new TestData());
     }
     Session["Log_t"] = null;
     Session["HasQueried_t"] = null;
     return RedirectToAction("Index");
 }
コード例 #3
0
 public ActionResult BindTestCase(TestData testdata)
 {
     ActionResult ar = VerifyIfProjectSelected("PRJNAME");
     if (null != ar) return ar;
     if (null != testdata.TestCaseId)
     {
         Session["TestCaseBound"] = testdata.TestCaseId;
     }
     else
     {
         return View();
     }
     bool isExisting=this.TestDataService.ExistTestCase(testdata.TestCaseId);
     if (!isExisting)
     {
         Session["Log_bt"] = "The test case isn't existing.";
         return View();
     }
     return RedirectToAction("Index");
 }
コード例 #4
0
        private ActionResult Save(TestData updatedItem, int pageIndex)
        {
            int tdid = updatedItem.Id;
            if (null != updatedItem.TestCaseId || null != updatedItem.Name)
            {

                this.TestDataService.CurrentProjectId = (int)Session["PID"];
                string log = "";
                string tcid;
                if (null == Session["TestCaseBound"])
                    tcid = updatedItem.TestCaseId;
                else
                    tcid = Session["TestCaseBound"].ToString();
                TestData instance = new TestData { Id = tdid, TestCaseId=tcid, Name = updatedItem.Name, Value = updatedItem.Value };
                bool isSuccess = this.TestDataService.UpdateTestData(instance, out log);
                if (isSuccess)
                {
                    Session["Log_t"] = null;
                    Session["UpdatedId_t"] = null;
                    return RedirectToAction("Index", new { pageIndex = pageIndex });
                }
                Session["Log_t"] = log;
                return Edit(tdid, pageIndex);
            }
            Session["Log_t"] = "Test Case ID and Name Required!";
            return Edit(tdid, pageIndex);
        }