private void writeTestAutomationDefinition(TestAutomationDefinition testAutomationDefinition, XmlTextWriter xmlWriter) { // Automation values. xmlWriter.WriteElementString("Assembly", (testAutomationDefinition.TestAssembly == null) ? null : testAutomationDefinition.TestAssembly); xmlWriter.WriteElementString("Class", testAutomationDefinition.TestClass); xmlWriter.WriteElementString("Method", testAutomationDefinition.TestMethod); xmlWriter.WriteStartElement("Parameters"); // If test parameters exist, write. if (testAutomationDefinition.TestParameters != null) { foreach (TestParameter param in testAutomationDefinition.TestParameters) { // Writes parent element name. xmlWriter.WriteStartElement("Parameter"); // Write element attributes for name. xmlWriter.WriteAttributeString("key", param.Name); xmlWriter.WriteAttributeString("dtype", param.TypeAsString); xmlWriter.WriteAttributeString("value", param.ValueAsString); // Ends parent element. xmlWriter.WriteEndElement(); } } xmlWriter.WriteEndElement(); }
/// <summary> /// Displays test parameters dialog for edit from properties window. /// </summary> /// <param name="context"></param> /// <param name="provider"></param> /// <param name="value"></param> /// <returns></returns> public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { PropertyGrid grid = provider.GetType().GetProperty("OwnerGrid").GetGetMethod().Invoke(provider, null) as PropertyGrid; TestSuite testSuite = grid.SelectedObject as TestSuite; TestAutomationDefinition definition = null; if (context.Instance is TestPreprocessor) { TestScriptObjectEditorDialog dlg = new TestScriptObjectEditorDialog(null, testSuite.TestPreprocessor); DialogResult result = dlg.ShowDialog(); definition = testSuite.TestPreprocessor.TestAutomationDefinition; } else if (context.Instance is TestPostprocessor) { TestScriptObjectEditorDialog dlg = new TestScriptObjectEditorDialog(null, testSuite.TestPostprocessor); DialogResult result = dlg.ShowDialog(); definition = testSuite.TestPostprocessor.TestAutomationDefinition; } return(definition); }