public void SerializeProjectDetectorConfiguration() { // Open a project IProject project1 = TestFramework.ProjectManager.CreateProject(ProjectPath, ProjectInvestigator, DateTime.Now, ProjectDescription); // Change detector configuration IDetector mockConfigurableDetector = TestFramework.DetectorFactory.Detectors.Single(detector => detector.Name == "MockConfigurableDetector"); IConfigurationItem configurationItem = (mockConfigurableDetector as IConfigurable).Configuration.ElementAt(0); Assert.That((int)configurationItem.Value, Is.EqualTo(123)); configurationItem.SetUserValue("456"); Assert.That((int)configurationItem.Value, Is.EqualTo(456)); // Save the project containing the detector configuration TestFramework.ProjectManager.SaveProject(project1); TestFramework.ProjectManager.CloseProject(project1); // Change the detector configuration configurationItem.SetUserValue("123"); // Check the change made Assert.That((int)configurationItem.Value, Is.EqualTo(123)); // Open project IProject project2 = TestFramework.ProjectManager.OpenProject(ProjectPath); // Check the detector configuration Assert.That((int)configurationItem.Value, Is.EqualTo(456)); TestFramework.ProjectManager.CloseProject(project2); }
/// <summary> /// Accept the changes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonOKClick(object sender, EventArgs e) { foreach (Control control in tabControlConfiguration.Controls) { if (!(control is TabPage)) { continue; } foreach (Control tableLayoutControl in control.Controls) { TableLayoutPanel tableLayoutPanel = tableLayoutControl as TableLayoutPanel; if (tableLayoutPanel == null) { continue; } for (int rowIndex = 1; rowIndex < tableLayoutPanel.RowCount; rowIndex++) { TextBox userValue = tableLayoutPanel.GetControlFromPosition(2, rowIndex) as TextBox; IConfigurationItem configurationItem = userValue.Tag as IConfigurationItem; configurationItem.SetUserValue(userValue.Text); } } } }