예제 #1
0
        public virtual void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence h = new XmlPersistence();

            h.SaveSimpleField(element, "@name", this.name, null);
            h.SaveSimpleField(element, "@storage", this.storage, string.Empty);
            h.SaveSimpleField(element, "@priority", this.priority, DefaultPriority);
            h.SaveSimpleField(element, "Owners/Owner/@name", this.owner, string.Empty);
            h.SaveObject(this.testCategories, element, "TestCategory", parameters);

            if (this.executionId != null)
            {
                h.SaveGuid(element, "Execution/@id", this.executionId.Id);
            }
            if (this.parentExecutionId != null)
            {
                h.SaveGuid(element, "Execution/@parentId", this.parentExecutionId.Id);
            }

            h.SaveObject(this.workItems, element, "Workitems", parameters);

            XmlTestStoreParameters testIdParameters = XmlTestStoreParameters.GetParameters();

            testIdParameters[TestId.IdLocationKey] = "@id";
            h.SaveObject(this.id, element, testIdParameters);
        }
예제 #2
0
        /// <summary>
        /// Saves the state to the XML element
        /// </summary>
        /// <param name="element">The XML element to save to</param>
        /// <param name="parameters">Parameters to customize the save behavior</param>
        public void Save(XmlElement element, XmlTestStoreParameters parameters)
        {
            EqtAssert.ParameterNotNull(element, "element");

            XmlPersistence helper = new XmlPersistence();

            helper.SaveSimpleField(element, "@agentName", this.agentName, null);
            helper.SaveSimpleField(element, "@agentDisplayName", this.agentDisplayName, this.agentName);
            helper.SaveSimpleField(element, "@isFromRemoteAgent", this.isFromRemoteAgent, false);
            helper.SaveSimpleField(element, "@uri", this.uri.AbsoluteUri, null);
            helper.SaveSimpleField(element, "@collectorDisplayName", this.collectorDisplayName, string.Empty);

            IList <UriDataAttachment> uriAttachments = new List <UriDataAttachment>();

            foreach (IDataAttachment attachment in this.Attachments)
            {
                UriDataAttachment uriAtt = attachment as UriDataAttachment;
                if (uriAtt != null)
                {
                    uriAttachments.Add(uriAtt);
                }
            }

            helper.SaveIEnumerable(uriAttachments, element, "UriAttachments", "A", "UriAttachment", parameters);
        }
예제 #3
0
        /// <summary>
        /// Saves the class under the XmlElement..
        /// </summary>
        /// <param name="element">
        /// The parent xml.
        /// </param>
        /// <param name="parameters">
        /// The parameter
        /// </param>
        public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence helper = new XmlPersistence();

            helper.SaveObject(this.id, element, ".", parameters);
            helper.SaveSimpleField(element, "@testName", this.testName, string.Empty);
            helper.SaveSimpleField(element, "@computerName", this.computerInfo, string.Empty);
            helper.SaveSimpleField(element, "@duration", this.duration, default(TimeSpan));
            helper.SaveSimpleField(element, "@startTime", this.startTime, default(DateTime));
            helper.SaveSimpleField(element, "@endTime", this.endTime, default(DateTime));
            helper.SaveGuid(element, "@testType", this.testType.Id);

            if (this.stdOut != null)
            {
                this.stdOut = this.stdOut.Trim();
            }

            if (this.stdErr != null)
            {
                this.stdErr = this.stdErr.Trim();
            }

            helper.SaveSimpleField(element, "@outcome", this.outcome, default(TestOutcome));
            helper.SaveSimpleField(element, "Output/StdOut", this.stdOut, string.Empty);
            helper.SaveSimpleField(element, "Output/StdErr", this.stdErr, string.Empty);
            helper.SaveSimpleField(element, "Output/DebugTrace", this.debugTrace, string.Empty);
            helper.SaveObject(this.errorInfo, element, "Output/ErrorInfo", parameters);

            helper.SaveGuid(element, "@testListId", this.categoryId.Id);

            helper.SaveIEnumerable(this.textMessages, element, "Output/TextMessages", ".", "Message", parameters);
            helper.SaveSimpleField(element, "@relativeResultsDirectory", this.relativeTestResultsDirectory, null);
            helper.SaveIEnumerable(this.resultFiles.Keys, element, "ResultFiles", "@path", "ResultFile", parameters);
            helper.SaveIEnumerable(this.collectorDataEntries, element, "CollectorDataEntries", ".", "Collector", parameters);
        }
예제 #4
0
        public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence h = new XmlPersistence();

            h.SaveGuid(element, "@id", this.Id);
            h.SaveSimpleField(element, "@name", this.name, null);
            h.SaveSimpleField(element, "@storage", this.storage, string.Empty);
        }
예제 #5
0
        /// <summary>
        /// Saves the class under the XmlElement..
        /// </summary>
        /// <param name="element">
        /// The parent xml.
        /// </param>
        /// <param name="parameters">
        /// The parameter
        /// </param>
        public void Save(XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence helper = new XmlPersistence();

            helper.SaveSimpleField(element, "@className", this.className, string.Empty);
            helper.SaveSimpleField(element, "@name", this.name, string.Empty);
            helper.SaveSimpleField(element, "isValid", this.isValid, false);
        }
예제 #6
0
        /// <summary>
        /// Saves the class under the XmlElement..
        /// </summary>
        /// <param name="element">
        /// The parent xml.
        /// </param>
        /// <param name="parameters">
        /// The parameter
        /// </param>
        public override void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters)
        {
            base.Save(element, parameters);
            XmlPersistence h = new XmlPersistence();

            h.SaveSimpleField(element, "TestMethod/@codeBase", this.codeBase, string.Empty);
            h.SaveSimpleField(element, "TestMethod/@adapterTypeName", this.adapter, string.Empty);
            h.SaveObject(this.testMethod, element, "TestMethod", parameters);
        }
예제 #7
0
        /// <summary>
        /// Saves the class under the XmlElement..
        /// </summary>
        /// <param name="element">
        /// The parent xml.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        public void Save(XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence helper = new XmlPersistence();

            helper.SaveSingleFields(element, this, parameters);
            helper.SaveSimpleField(element, "Exception", this.exception, null);
        }
예제 #8
0
        /// <summary>
        /// Saves the class under the XmlElement.
        /// </summary>
        /// <param name="element">
        /// The parent xml.
        /// </param>
        /// <param name="parameters">
        /// The parameter
        /// </param>
        public void Save(XmlElement element, XmlTestStoreParameters parameters)
        {
            EqtAssert.ParameterNotNull(element, "element");

            XmlPersistence helper = new XmlPersistence();

            helper.SaveSimpleField(element, ".", this.description, null);

            // The URI is not a true URI, it must always be a local path represented as a URI. Also, the URI can be absolute or
            // relative. We use OriginalString because:
            //   - ToString gets a string in the form "file://..." for an absolute URI and what was passed in for a relative URI
            //   - AbsoluteUri only works for an absolute URI naturally
            //   - LocalPath only works for an absolute URI
            // Due to the above assumption, that it is always an absolute or relative local path to a file, it's simplest and
            // safest to treat the URI as a string and just use OriginalString.
            helper.SaveSimpleField(element, "@href", this.uri.OriginalString, null);
        }
예제 #9
0
        /// <summary>
        /// Saves the class under the XmlElement..
        /// </summary>
        /// <param name="element">
        /// The parent xml.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        public void Save(XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence helper = new XmlPersistence();

            // Save all fields marked as StoreXmlSimpleField.
            helper.SaveSingleFields(element, this, parameters);

            helper.SaveGuid(element, "@id", this.id.Id);

            // When saving and loading a TRX file, we want to use the run deployment root directory based on where the TRX file
            // is being saved to or loaded from
            object filePersistenceRootObjectType;

            if (parameters.TryGetValue(XmlFilePersistence.RootObjectType, out filePersistenceRootObjectType) &&
                (Type)filePersistenceRootObjectType == typeof(TestRun))
            {
                Debug.Assert(
                    parameters.ContainsKey(XmlFilePersistence.DirectoryPath),
                    "TestRun is the type of the root object being saved to a file, but the DirectoryPath was not specified in the XML test store parameters");

                Debug.Assert(
                    !string.IsNullOrEmpty(this.runDeploymentRoot),
                    "TestRun is the type of the root object being saved to a file, but the run deployment root directory is null or empty");

                // We are saving a TestRun object as the root element in a file (TRX file), so just save the test run directory
                // name (last directory in the run deployment root), which is the relative path to the run deployment root
                // directory from the directory where the TRX file exists
                helper.SaveSimpleField(
                    element,
                    "Deployment/@runDeploymentRoot",
                    FileHelper.MakePathRelative(this.runDeploymentRoot, Path.GetDirectoryName(this.runDeploymentRoot)),
                    string.Empty);
            }
            else
            {
                // We are not saving a TestRun object as the root element in a file (i.e., we're not saving a TRX file), so just
                // save the run deployment root directory as is
                helper.SaveSimpleField(element, "Deployment/@runDeploymentRoot", this.runDeploymentRoot, string.Empty);
            }
        }
예제 #10
0
        /// <summary>
        /// Saves the class under the XmlElement..
        /// </summary>
        /// <param name="element">
        /// The parent xml.
        /// </param>
        /// <param name="parameters">
        /// The parameter
        /// </param>
        public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence h = new XmlPersistence();

            h.SaveSimpleField(element, "@name", this.name, null);
            h.SaveSimpleField(element, "@storage", this.storage, string.Empty);
            h.SaveSimpleField(element, "@priority", this.priority, DefaultPriority);
            h.SaveSimpleField(element, "Owners/Owner/@name", this.owner, string.Empty);
            h.SaveObject(this.testCategories, element, "TestCategory", parameters);

            // Save the test ID. We exclude "test" from the default locations used by TestId, since this is already a test
            // element. Ideally, we would let TestId save the IDs to the default locations, but the previous behavior of
            // TestElement was to store the test ID at @testId, and since we can't change this, TestId supports custom
            // locations for the IDs. See TestId.GetLocations for more info.
            XmlTestStoreParameters testIdParameters = XmlTestStoreParameters.GetParameters();

            testIdParameters[TestId.IdLocationKey] = "@id";
            h.SaveObject(this.id, element, testIdParameters);

            if (this.executionId != null)
            {
                h.SaveGuid(element, "Execution/@id", this.executionId.Id);
            }

            h.SaveSimpleField(element, "TestMethod/@codeBase", this.codeBase, string.Empty);
            h.SaveSimpleField(element, "TestMethod/@executorUriOfAdapter", this.executorUriOfAdapter, string.Empty);
            h.SaveObject(this.testMethod, element, "TestMethod", parameters);
        }