Exemplo n.º 1
0
        private void SaveSuites()
        {
            var suiteNameSet = new HashSet <string>();

            foreach (var item in _testsFromXml.ListOfTests)
            {
                suiteNameSet.Add(item.TestSuite);
            }

            using (var db = new testsettingsEntities())
            {
                foreach (var name in suiteNameSet)
                {
                    var inDb = db.testsuites.FirstOrDefault(i => i.testsuitename == name);

                    // Item already in db
                    if (inDb != null)
                    {
                        continue;
                    }

                    // Item not in db
                    db.testsuites.Add(new testsuite
                    {
                        testsuitename = name
                    });

                    db.SaveChanges();
                }
            }
        }
Exemplo n.º 2
0
        private void SaveTests()
        {
            using (var db = new testsettingsEntities())
            {
                foreach (var item in _testsFromXml.ListOfTests)
                {
                    var inDb = db.testcases.FirstOrDefault(i => i.testcasename.Equals(item.TestName));

                    // Item alrady in db
                    if (inDb != null)
                    {
                        continue;
                    }

                    // Item not in db
                    var suite = db.testsuites.FirstOrDefault(i => i.testsuitename == item.TestSuite);

                    if (suite == null)
                    {
                        throw new Exception("TestSuite not found");
                    }

                    db.testcases.Add(new testcase
                    {
                        testcasename        = item.TestName,
                        belongstosuite      = suite.testsuiteid,
                        testcasedescription = item.TestCaseDescription,
                        testsuite           = suite
                    });

                    db.SaveChanges();
                }
            }
        }
        private void SaveResults()
        {
            var db = new testsettingsEntities();

            db.testruns.Add(_result);
            db.SaveChanges();
            db.Dispose();
        }
        public static void DeactivateAll()
        {
            var db       = new testsettingsEntities();
            var toUpdate = db.settings.Where(item => item.isActive == 1).ToList();

            toUpdate.ForEach(i => i.isActive = 0);
            db.SaveChanges();
            db.Dispose();
        }
        public ActionResult DeleteConfirmed(int id)
        {
            using (var db = new testsettingsEntities())
            {
                var item = db.settings.Find(id);

                if (item == null)
                {
                    throw new NoNullAllowedException("Id field can't be null.");
                }

                db.settings.Remove(item);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
        }
        public ActionResult Edit([Bind(Include = "id,targetBrowser,operatingSystem,seleniumHubUri,screenshotFolder,isActive")] setting setting)
        {
            if (!ModelState.IsValid)
            {
                return(View(setting));
            }

            using (var db = new testsettingsEntities())
            {
                if (setting.isActive == 1)
                {
                    Database.DbHelpers.DeactivateAll();
                }

                db.Entry(setting).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
        }
        public ActionResult Create([Bind(Include = "id,targetBrowser,operatingSystem,seleniumHubUri,screenshotFolder,isActive")] setting setting)
        {
            setting.id = Database.DbHelpers.GetNextId();

            using (var db = new testsettingsEntities())
            {
                if (ModelState.IsValid)
                {
                    if (setting.isActive == 1)
                    {
                        Database.DbHelpers.DeactivateAll();
                    }

                    db.settings.Add(setting);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }

                return(View(setting));
            }
        }