public override void BindChildren() { Benchmark.TestGroup testGroup = (Benchmark.TestGroup)BenchmarkObject; this.Nodes.Clear(); configurationsNode = new FolderTreeNode(BenchmarkTreeView); configurationsNode.Text = "Configurations"; configurationsNode.ImageKey = "Folder"; configurationsNode.SelectedImageKey = "Folder"; BindCollection <Benchmark.Configuration>(configurationsNode, testGroup.Configurations); this.Nodes.Add(configurationsNode); testsNode = new FolderTreeNode(BenchmarkTreeView); testsNode.Text = "Tests"; testsNode.ImageKey = "Folder"; testsNode.SelectedImageKey = "Folder"; BindCollection <Benchmark.Test>(testsNode, testGroup.Tests); this.Nodes.Add(testsNode); configurationsContextMenu = new ContextMenuStrip(); configurationsContextMenu.Items.Add("Add", Properties.Resources.Add_16, AddConfiguration_Click); configurationsNode.ContextMenuStrip = configurationsContextMenu; testsContextMenu = new ContextMenuStrip(); testsContextMenu.Items.Add("Add", Properties.Resources.Add_16, AddTest_Click); testsContextMenu.Items.Add(new ToolStripSeparator()); testsContextMenu.Items.Add("Activate all tests in group", Properties.Resources.CheckAll_16, ActivateAllTests_Click); testsContextMenu.Items.Add("Deactivate all tests in group", Properties.Resources.UncheckAll_16, DeactivateAllTests_Click); testsNode.ContextMenuStrip = testsContextMenu; ChildrenBound = true; }
private void DeactivateAllTests_Click(object sender, EventArgs e) { Benchmark.TestGroup testGroup = (Benchmark.TestGroup)BenchmarkObject; foreach (Benchmark.Test test in testGroup.Tests) { test.Active = false; } }
public override void BindNode() { BindNamedObjectText(); Benchmark.TestGroup testGroup = (Benchmark.TestGroup)BenchmarkObject; this.ImageKey = "TestGroup"; this.SelectedImageKey = "TestGroup"; testGroupContextMenu = new ContextMenuStrip(); testGroupContextMenu.Items.Add("Rename", Properties.Resources.Rename_16, Rename_Click); testGroupContextMenu.Items.Add("Remove", Properties.Resources.Remove_16, Remove_Click); this.ContextMenuStrip = testGroupContextMenu; }
private void AddConfiguration_Click(object sender, EventArgs e) { Benchmark.TestGroup testGroup = (Benchmark.TestGroup)BenchmarkObject; Benchmark.Configuration configuration = new Benchmark.Configuration(testGroup); configuration.Name = Helpers.GetNewName(testGroup.Configurations.Select(c => c.Name), "new configuration", NumeralStyle.Guess); configuration.Number = Helpers.GetNewName(testGroup.Configurations.Select(c => c.Number), null, NumeralStyle.AlphabeticUpper); testGroup.Configurations.Add(configuration); TreeNode newNode = BenchmarkTreeView.GetTreeNode(configuration); if (newNode != null) { BenchmarkTreeView.TreeView.SelectedNode = newNode; newNode.BeginEdit(); } }
private void AddTest_Click(object sender, EventArgs e) { Benchmark.TestGroup testGroup = (Benchmark.TestGroup)BenchmarkObject; Benchmark.PlanEquivalenceTest planEquivalenceTest = new Benchmark.PlanEquivalenceTest(testGroup); planEquivalenceTest.Name = Helpers.GetNewName(testGroup.Tests.Select(t => t.Name), "new test", NumeralStyle.Guess); planEquivalenceTest.Number = Helpers.GetNewName(testGroup.Tests.Select(t => t.Number), null, NumeralStyle.Arabic); testGroup.Tests.Add(planEquivalenceTest); TreeNode newNode = BenchmarkTreeView.GetTreeNode(planEquivalenceTest); if (newNode != null) { BenchmarkTreeView.TreeView.SelectedNode = newNode; newNode.BeginEdit(); } }
private void AddTestGroup_Click(object sender, EventArgs e) { Benchmark.Benchmark benchmark = (Benchmark.Benchmark)BenchmarkObject; Benchmark.TestGroup testGroup = new Benchmark.TestGroup(benchmark); testGroup.Name = Helpers.GetNewName(benchmark.TestGroups.Select(g => g.Name), "new test group", NumeralStyle.Guess); testGroup.Number = Helpers.GetNewName(benchmark.TestGroups.Select(g => g.Number), null, NumeralStyle.RomanUpper); benchmark.TestGroups.Add(testGroup); TreeNode newNode = BenchmarkTreeView.GetTreeNode(testGroup); if (newNode != null) { BenchmarkTreeView.TreeView.SelectedNode = newNode; newNode.BeginEdit(); } }
private void Remove_Click(object sender, EventArgs e) { Benchmark.TestGroup testGroup = (Benchmark.TestGroup)BenchmarkObject; testGroup.Benchmark.TestGroups.Remove(testGroup); }
public TestGroupTreeNode(Benchmark.TestGroup testGroup, BenchmarkTreeView benchmarkTreeView) : base(testGroup, benchmarkTreeView) { }
private void PreparePlanEquivalenceTest(Benchmark.PlanEquivalenceTest planEquivalenceTest, Benchmark.Test test, Benchmark.TestGroup testGroup, Benchmark.Configuration configuration, DbProviders.DbProvider db, Benchmark.Template template = null) { Benchmark.PlanEquivalenceTestResult planEquivalenceTestResult = new Benchmark.PlanEquivalenceTestResult(testRun); planEquivalenceTestResult.TestId = test.Id; planEquivalenceTestResult.TestNumber = test.Number; planEquivalenceTestResult.TestName = test.Name; planEquivalenceTestResult.TestGroupId = testGroup.Id; planEquivalenceTestResult.ConfigurationId = configuration.Id; if (template != null) { planEquivalenceTestResult.TemplateNumber = template.Number; } foreach (Benchmark.QueryVariant variant in planEquivalenceTest.Variants) { if (IgnoreVariant(variant)) { continue; } Benchmark.QueryVariantResult queryVariantResult = new Benchmark.QueryVariantResult(planEquivalenceTestResult); Benchmark.Statement statement = variant.GetStatement(db.Name); // Skip not supported variants. if (statement is Benchmark.SpecificStatement specificStatement) { if (specificStatement.NotSupported) { continue; } } foreach (Benchmark.SelectedAnnotation selectedAnnotation in variant.SelectedAnnotations) { Benchmark.SelectedAnnotationResult selectedAnnotationResult = new Benchmark.SelectedAnnotationResult(queryVariantResult); selectedAnnotationResult.AnnotationId = selectedAnnotation.AnnotationId; queryVariantResult.SelectedAnnotationResults.Add(selectedAnnotationResult); } string commandText = statement.CommandText; if (template != null) { // Parametrized template substitution. foreach (Benchmark.Parameter parameter in planEquivalenceTest.Parameters) { Benchmark.ParameterValue parameterValue = planEquivalenceTest.ParameterValues.Where(pv => pv.ParameterId == parameter.Id && pv.TemplateId == template.Id).FirstOrDefault(); if (parameterValue != null) { string paramStr = Controls.Helpers.GetParamStr(parameter.Name); commandText = commandText.Replace(paramStr, parameterValue.Value); } } } queryVariantResult.Query = commandText; queryVariantResult.QueryVariantId = variant.Id; queryVariantResult.QueryVariantNumber = variant.Number; queryVariantResult.QueryVariantName = variant.Name; if (template != null) { queryVariantResult.ExpectedResultSize = template.ExpectedResultSize; } else { queryVariantResult.ExpectedResultSize = planEquivalenceTest.ExpectedResultSize; } // Token analysis. try { Classes.SqlScanner scanner = new Classes.SqlScanner(commandText); scanner.Scan(); queryVariantResult.TokenCount = scanner.Tokens.Length; } catch { queryVariantResult.TokenCount = -1; } planEquivalenceTestResult.QueryVariantResults.Add(queryVariantResult); } foreach (Benchmark.SelectedAnnotation selectedAnnotation in planEquivalenceTest.SelectedAnnotations) { Benchmark.SelectedAnnotationResult selectedAnnotationResult = new Benchmark.SelectedAnnotationResult(planEquivalenceTestResult); selectedAnnotationResult.AnnotationId = selectedAnnotation.AnnotationId; planEquivalenceTestResult.SelectedAnnotationResults.Add(selectedAnnotationResult); } if (template != null) { foreach (Benchmark.SelectedAnnotation selectedAnnotation in template.SelectedAnnotations) { Benchmark.SelectedAnnotationResult selectedAnnotationResult = new Benchmark.SelectedAnnotationResult(planEquivalenceTestResult); selectedAnnotationResult.AnnotationId = selectedAnnotation.AnnotationId; selectedAnnotationResult.IsTemplateAnnotation = true; planEquivalenceTestResult.SelectedAnnotationResults.Add(selectedAnnotationResult); } } if (planEquivalenceTestResult.QueryVariantResults.Count > 0) { testRun.TestResults.Add(planEquivalenceTestResult); } }