/////// <summary> /////// Saves the project into result file. /////// </summary> /////// <param name="testProject"> /////// The test project. /////// </param> ////private void SaveProject(TestProject testProject) ////{ //// UpdateProjectElement(testProject); //// SaveContent(this.document, this.ResultFile); ////} /// <summary> /// Updates the project element in this instance. /// </summary> /// <param name="testProject"> /// The test project. /// </param> private static void UpdateProjectElement(TestProject testProject) { if (testProject == null) { throw new ArgumentNullException("testProject", "Cannont save null project to test result."); } if (testProject.Saved) { return; } XElement projectElement = InitTestProject(testProject); UpdateEntityElement(testProject, projectElement); // Update testClasses of this test project testProject.TestClasses.ForEach(UpdateTestClassElement); testProject.Saved = true; }
/// <summary> /// Initialize the test project. /// </summary> /// <param name="entity"> /// The test project. /// </param> /// <returns> /// The <see cref="XElement"/>. /// </returns> /// <exception cref="NullReferenceException"> /// </exception> private static XElement InitTestProject(TestProject entity) { if (entity.TestResult == null) { throw new InvalidOperationException( string.Format("Test project [{0}] is not linked with a test result.", entity.Name)); } TestResult testResult = entity.TestResult; // Get the root from loaded xml result file XElement parent = testResult.document.Root; if (parent == null) { throw new InvalidDataException("Test document root was not initialized properly."); } XElement project = GetEntityElement(entity, parent, Constants.ProjectElement); if (project == null) { project = ConstructEntityXElement(entity, Constants.ProjectElement); parent.Add(project); } return project; }