Exemplo n.º 1
0
        private void SaveSuites(IConfiguration configuration)
        {
            var suiteNames   = _testsFromXml.ListOfTests.Select(i => i.TestSuite).ToList();
            var suiteNameSet = new HashSet <string>(suiteNames);
            var db           = DbHelpers.OpenDbConnection(configuration);

            foreach (var name in suiteNameSet)
            {
                var inDb = db.Testsuites.FirstOrDefault(i => i.TestsuiteName == name);

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

                // Suite not in db
                db.Testsuites.Add(new Testsuite {
                    TestsuiteName = name
                });
                db.SaveChanges();
            }

            db.Dispose();
        }
        private void SaveResults(IConfiguration configuration)
        {
            var db = DbHelpers.OpenDbConnection(configuration);

            db.Testruns.Add(_result);
            db.SaveChanges();
            db.Dispose();
        }
Exemplo n.º 3
0
        private static Setting GetDataFromDb(IConfiguration configuration)
        {
            var db      = DbHelpers.OpenDbConnection(configuration);
            var setting = db.Settings.FirstOrDefault(item => item.IsActive == 1);

            db.Dispose();

            return(setting);
        }
Exemplo n.º 4
0
        private void SaveTests(IConfiguration configuration)
        {
            var db = DbHelpers.OpenDbConnection(configuration);

            foreach (var item in _testsFromXml.ListOfTests)
            {
                var inDb = db.Testcases.FirstOrDefault(i => i.TestcaseName == item.TestName);

                // Item already 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");
                }

                var newTest = new Testcase
                {
                    TestcaseName        = item.TestName,
                    BelongsToSuite      = suite.TestsuiteId,
                    TestcaseDescription = item.TestCaseDescription,
                    TestSuite           = suite
                };

                db.Testcases.Add(newTest);
                db.SaveChanges();
            }

            db.Dispose();
        }
 public SettingsController(IConfigurationRoot configuration)
 {
     Configuration = configuration;
     Db            = DbHelpers.OpenDbConnection(Configuration);
 }