Пример #1
0
        /// <summary>
        /// Enable or disable one single testrun
        /// </summary>
        /// <param name="testname"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public void EnableTestrun(string testname, bool value)
        {
            testrun tr = _database.testrun.Where(t => t.name == testname).First();

            tr.enabled = value ? 1 : 0;
            _database.SaveChanges();
        }
Пример #2
0
        /// <summary>
        /// Get testrun ID or create if not exist (optional)
        ///  returns 0 if not exist and not created
        /// </summary>
        /// <param name="testrunName"></param>
        /// <param name="createIfNotExist"></param>
        /// <returns></returns>
        private int GetTestrunId(string testrunName, bool createIfNotExist)
        {
            if ((!_refTestrun.ContainsKey(testrunName)) && createIfNotExist)
            {
                Log.WriteLine(string.Format("testrun [{0}] not found, adding it...", testrunName));

                testrun tr = new testrun();
                tr.name       = testrunName;
                tr.project_id = _projectId;
                tr.enabled    = 1;

                var newTestrun = _database.testrun.Add(tr);
                _database.SaveChanges();

                RefreshRefTestrun(); // new id is inserted in _refTestrun string array by this refresh
            }

            string testrunId = GetSaveIdFromRefTestrun(testrunName);

            if (testrunId == "0")
            {
                Log.WriteLine(string.Format("WARNING testrun [{0}] not found in database", testrunId));
            }

            return(int.Parse(testrunId));


            ////Log.WriteLine("get testrun id for {0}...", testrunName);
            //if ((!_refTestrun.ContainsKey(testrunName)) && createIfNotExist)
            //{
            //    Log.WriteLine(string.Format("testrun [{0}] not found, adding it...", testrunName));
            //    ExecuteQuery(string.Format("insert into TESTRUN (project_id, name) values ({0},'{1}') returning id", _projectId, testrunName));
            //    RefreshRefTestrun(); // new id is inserted in _refTestrun string array by this refresh
            //}

            //return GetSafeIdFromRef(_refTestrun, testrunName);
        }