private void lnkTypeDefault_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (DialogResult.Yes == MessageBox.Show("Are you sure you want to insert default values?", "Confirm Insert", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { foreach (Control ctrl in pnlParameters.Controls) { if (ctrl is ParameterCtrl) { ParameterCtrl pC = (ParameterCtrl)ctrl; pC.ParameterTextValue = TestManager.GetDefaultValueForSqlDbType(pC.DbType); pC.Parameter.Value = pC.ParameterTextValue; } } } }
private void lnkPasteParameters_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { PasteScriptForm frmScript = new PasteScriptForm(); if (DialogResult.OK == frmScript.ShowDialog()) { Dictionary <string, string> paramvalues = TestManager.ParseParameterValuesFromScript(this.sprocName, RetrieveParameterNames(), frmScript.ScriptText); foreach (Control ctrl in pnlParameters.Controls) { if (ctrl is ParameterCtrl) { ParameterCtrl pC = (ParameterCtrl)ctrl; if (paramvalues.ContainsKey(pC.Parameter.Name)) { pC.Parameter.Value = paramvalues[pC.Parameter.Name]; pC.ParameterTextValue = paramvalues[pC.Parameter.Name]; } } } } }
private void BindData() { this.grpTestCase.Text = "Test Case Definition for " + this.sprocName; pnlParameters.Controls.Clear(); pnlOutput.Controls.Clear(); List <ParameterCtrl> paramCtrls = new List <ParameterCtrl>(); this.txtCaseName.Text = this.tCase.Name; this.ddExecutionType.SelectedItem = this.tCase.ExecuteType; #region Add Parameter controls bool foundMatch; Point paramStart = new Point(3, 3); if (derivedParameters != null && derivedParameters.Count > 0) { //Loop through derived parameters and match to test case. for (int i = 0; i < derivedParameters.Count; i++) { foundMatch = false; if (this.tCase.Parameter != null) { for (int j = 0; j < this.tCase.Parameter.Length; j++) { if (this.tCase.Parameter[j].Name.ToLower() == this.derivedParameters[i].ParameterName.ToLower()) { this.tCase.Parameter[j].HasDerivedParameterMatch = true; ParameterCtrl ctrl = new ParameterCtrl(ref this.tCase.Parameter[j]); ctrl.ParameterStatus = ParameterStatus.Matching; ctrl.DbType = this.derivedParameters[i].SqlDbType; ctrl.DbLength = this.derivedParameters[i].Size; paramCtrls.Add(ctrl); foundMatch = true; break; // new Int32Converter().ConvertFrom(this.derivedParameters[i].Precision) } } } if (!foundMatch) { ParameterCtrl ctrl = new ParameterCtrl(this.derivedParameters[i].ParameterName); ctrl.ParameterStatus = ParameterStatus.NotInTestCase; ctrl.DbType = this.derivedParameters[i].SqlDbType; ctrl.DbLength = this.derivedParameters[i].Size; paramCtrls.Add(ctrl); } } //Loop through the test case and add any "extra" parameters. if (this.tCase.Parameter != null) { for (int i = 0; i < this.tCase.Parameter.Length; i++) { if (!this.tCase.Parameter[i].HasDerivedParameterMatch) { ParameterCtrl ctrl = new ParameterCtrl(ref this.tCase.Parameter[i]); ctrl.ParameterStatus = ParameterStatus.NotInDatabase; paramCtrls.Add(ctrl); } } } } else if (this.tCase.Parameter != null) { //If there are no derived parameters... for (int i = 0; i < this.tCase.Parameter.Length; i++) { ParameterCtrl ctrl = new ParameterCtrl(ref this.tCase.Parameter[i]); ctrl.ParameterStatus = ParameterStatus.NotInDatabase; paramCtrls.Add(ctrl); } } for (int i = 0; i < paramCtrls.Count; i++) { paramCtrls[i].Location = paramStart; paramStart.Y += paramCtrls[i].Height; paramCtrls[i].Width = pnlParameters.Width - 10; paramCtrls[i].RemoveParameter += new EventHandler(SprocTestConfigCtrl_RemoveParameter); paramCtrls[i].DataChanged += new EventHandler(ChildData_DataChanged); paramCtrls[i].Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; pnlParameters.Controls.Add(paramCtrls[i]); } #endregion if (this.tCase.ExpectedResult != null) { if (this.tCase.ExpectedResult.RowCountSpecified) { this.txtRowCount.Text = this.tCase.ExpectedResult.RowCount.ToString(); } else { this.txtRowCount.Text = ""; } if (this.tCase.ExpectedResult.ColumnCountSpecified) { this.txtColumnCount.Text = this.tCase.ExpectedResult.ColumnCount.ToString(); } else { this.txtColumnCount.Text = ""; } if (this.tCase.ExpectedResult.RowCountOperatorSpecified) { this.ddRowCountOperator.SelectedItem = this.tCase.ExpectedResult.RowCountOperator; } else { this.ddRowCountOperator.SelectedItem = RowCountOperator.EqualTo; } this.ddResultType.SelectedItem = this.tCase.ExpectedResult.ResultType; #region Add Output Controls List <OutputResultCtrl> outputCtrls = new List <OutputResultCtrl>(); Point outputStart = new Point(3, 3); if (this.tCase.ExpectedResult.OutputResult != null) { for (int i = 0; i < this.tCase.ExpectedResult.OutputResult.Length; i++) { OutputResultCtrl ctrl = new OutputResultCtrl(ref this.tCase.ExpectedResult.OutputResult[i]); outputCtrls.Add(ctrl); } } for (int i = 0; i < outputCtrls.Count; i++) { outputCtrls[i].Location = outputStart; outputStart.Y += outputCtrls[i].Height; outputCtrls[i].DataChanged += new EventHandler(ChildData_DataChanged); outputCtrls[i].RemoveOutputResult += new EventHandler(SprocTestConfigCtrl_RemoveOutputResult); outputCtrls[i].Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; outputCtrls[i].Width = pnlOutput.Width - 10; pnlOutput.Controls.Add(outputCtrls[i]); } #endregion } ddExecutionType_SelectionChangeCommitted(null, EventArgs.Empty); ddResultType_SelectionChangeCommitted(null, EventArgs.Empty); this.DataChanged = false; }