Ejemplo n.º 1
0
        private void listTests_DoubleClick(object sender, EventArgs e)
        {
            if (listTests.FocusedItem != null)
            {
                using (var db = new DataContext())
                {
                    var test = Models.Test.Find(db, (int)listTests.FocusedItem.Tag);
                    if (test == null)
                    {
                        MessageBox.Show("Unable to load test.");
                        return;
                    }

                    var form = new Forms.EditTest(test);
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        // Save changes
                        test.Name   = form.TestName;
                        test.Script = form.Script;
                        test.SetParameters(db, form.Parameters);

                        db.SaveChanges();
                        LoadTests();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void btnAddTest_Click(object sender, EventArgs e)
        {
            var form = new Forms.EditTest();

            if (form.ShowDialog() == DialogResult.OK)
            {
                using (var db = new DataContext())
                {
                    var test = new Models.Test
                    {
                        Name       = form.TestName,
                        Script     = form.Script,
                        Parameters = new List <Models.TestParameter>()
                    };

                    db.Tests.Add(test);
                    test.SetParameters(db, form.Parameters);;

                    db.SaveChanges();
                }

                LoadTests();
            }
        }