Beispiel #1
0
        public void PerformanceRunSetupWithoutMenu()
        {
            int       SelectedTest_ID = 4;
            int       Test_ID;
            int       AutoVer_ID;
            DataTable AutomationIDs = new DataTable();
            XDocument xdoc          = XDocument.Load("test.config");
            IEnumerable <XElement> TestParameters;
            SqlConnection          conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MetricsRepository"].ConnectionString);

            TestParameters = from TestParameter in xdoc.Descendants("testParameters")
                             select TestParameter;

            DataTable TestTypes = new DataTable();

            string tbTestName = "BaseLine Collected:" + System.DateTime.Now.ToShortDateString();

            string AutomationVersion = FileVersionInfo.GetVersionInfo(Process.GetCurrentProcess().MainModule.FileName).FileVersion;

            SqlCommand SaveTest = new SqlCommand("INSERT INTO TestCase (Name,Type_ID) Values(@Name,@Type_ID); SELECT SCOPE_IDENTITY();", conn);

            SaveTest.Parameters.AddWithValue("@Name", tbTestName);
            SaveTest.Parameters.AddWithValue("@Type_ID", SelectedTest_ID);

            SqlCommand AutoVersion = new SqlCommand("SELECT AutoVer_ID FROM AutoVersion WHERE AutomationVersion = @FileVersion", conn);

            AutoVersion.Parameters.AddWithValue("@FileVersion", AutomationVersion);

            conn.Open();
            Test_ID = Convert.ToInt32(SaveTest.ExecuteScalar());
            SqlDataAdapter AutoDA = new SqlDataAdapter(AutoVersion);

            AutoDA.Fill(AutomationIDs);
            if (AutomationIDs.Rows.Count == 0)
            {
                SqlCommand AddAutoVersion = new SqlCommand("INSERT INTO AutoVersion (AutomationVersion) VALUES(@FileVersion); SELECT SCOPE_IDENTITY();", conn);
                AddAutoVersion.Parameters.AddWithValue("@FileVersion", AutomationVersion);
                AutoVer_ID = Convert.ToInt32(AddAutoVersion.ExecuteScalar());
            }
            else
            {
                AutoVer_ID = Convert.ToInt32(AutomationIDs.Rows[0][0]);
            }
            conn.Close();

            foreach (var TestParameter in TestParameters.Descendants())
            {
                if (TestParameter.Name == "type")
                {
                    TestParameter.Value = "performance";
                }
                if (TestParameter.Name == "test_ID")
                {
                    TestParameter.Value = Test_ID.ToString();
                }
                if (TestParameter.Name == "autoVer_ID")
                {
                    TestParameter.Value = AutoVer_ID.ToString();
                }
            }

            xdoc.Save("test.config");
        }