Ejemplo n.º 1
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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 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(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);
        }
Ejemplo n.º 6
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.SaveSingleFields(element, this, parameters);
            h.SaveGuid(element, "@id", this.Id.Id);
            h.SaveGuid(element, "@parentListId", this.ParentCategoryId.Id);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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.SaveSingleFields(element, this, parameters);
            helper.SaveIEnumerable(this.runLevelErrorsAndWarnings, element, "RunInfos", ".", "RunInfo", parameters);
            helper.SaveIEnumerable(this.resultFiles, element, "ResultFiles", "@path", "ResultFile", parameters);
            helper.SaveIEnumerable(this.collectorDataEntries, element, "CollectorDataEntries", ".", "Collector", parameters);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
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(System.Xml.XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence helper = new XmlPersistence();

            helper.SaveSingleFields(element, this, parameters);

            helper.SaveObject(this.testId, element, null);
            helper.SaveGuid(element, "@executionId", this.execId.Id);
            helper.SaveGuid(element, "@testListId", this.categoryId.Id);
        }
Ejemplo n.º 12
0
        public override void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters)
        {
            base.Save(element, parameters);

            XmlPersistence h = new XmlPersistence();

            if (testLinks.Count > 0)
            {
                h.SaveIEnumerable(testLinks.Values, element, "TestLinks", ".", "TestLink", parameters);
            }
        }
Ejemplo n.º 13
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();

            if (this.executionId != null)
            {
                helper.SaveGuid(element, "@executionId", this.executionId.Id);
            }

            helper.SaveObject(this.testId, element, null);
        }
        public override void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters)
        {
            base.Save(element, parameters);

            XmlPersistence helper = new XmlPersistence();

            if (this.InnerResults.Count > 0)
            {
                helper.SaveIEnumerable(this.InnerResults, element, "InnerResults", ".", null, parameters);
            }
        }
Ejemplo n.º 15
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>
        void IXmlTestStore.Save(XmlElement element, XmlTestStoreParameters parameters)
        {
            Debug.Assert(element != null, "element is null");

            string idLocation;

            this.GetIdLocation(parameters, out idLocation);

            XmlPersistence helper = new XmlPersistence();

            helper.SaveGuid(element, idLocation, this.id);
        }
Ejemplo n.º 16
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();

            if (this.executionId != Guid.Empty)
            {
                helper.SaveGuid(element, "@executionId", this.executionId);
            }
            if (this.parentExecutionId != Guid.Empty)
            {
                helper.SaveGuid(element, "@parentExecutionId", this.parentExecutionId);
            }

            helper.SaveGuid(element, "@testId", this.testId);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Gets the location of the test ID under an XML element, based on the specified parameters.
        /// This method is needed to parse the parameters sent by the caller of Save and Load.
        /// We need to support different locations for saving the test ID, because previously, TestEntry and TestResult stored the test ID to @testId
        /// (which is now the default location the TestId class' Save and Load methods), but TestElement was storing it to @id.
        /// Since we can't change the location where the ID is stored in XML, we support custom locations in the TestId class.
        /// </summary>
        /// <param name="parameters">The parameters specifying the locations</param>
        /// <param name="idLocation">The test ID location</param>
        private void GetIdLocation(XmlTestStoreParameters parameters, out string idLocation)
        {
            // Initialize to the default ID location
            idLocation = DefaultIdLocation;

            // If any parameters are specified, see if we need to override the defaults
            if (parameters != null)
            {
                object idLocationObj;
                if (parameters.TryGetValue(IdLocationKey, out idLocationObj))
                {
                    idLocation = idLocationObj as string ?? idLocation;
                }
            }
        }
Ejemplo n.º 18
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);
        }
Ejemplo n.º 19
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(System.Xml.XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence helper = new XmlPersistence();

            helper.SaveSingleFields(element, this, parameters);

            helper.SaveObject(this.testId, element, null);
            helper.SaveGuid(element, "@executionId", this.executionId);
            if (parentExecutionId != null)
            {
                helper.SaveGuid(element, "@parentExecutionId", this.parentExecutionId);
            }
            helper.SaveGuid(element, "@testListId", this.categoryId.Id);
            if (this.TestEntries.Count > 0)
            {
                helper.SaveIEnumerable(TestEntries, element, "TestEntries", ".", "TestEntry", parameters);
            }
        }
Ejemplo n.º 20
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);
            }
        }
Ejemplo n.º 21
0
        public override void Save(XmlElement element, XmlTestStoreParameters parameters)
        {
            XmlPersistence xmlPersistence = new XmlPersistence();

            xmlPersistence.SaveHashtable(this.container, element, ".", ".", null, "Workitem", parameters);
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Saves the class under the XmlElement.
 /// </summary>
 /// <param name="element"> XmlElement element </param>
 /// <param name="parameters"> XmlTestStoreParameters parameters</param>
 public void Save(System.Xml.XmlElement element, XmlTestStoreParameters parameters)
 {
     new XmlPersistence().SaveSingleFields(element, this, parameters);
 }
Ejemplo n.º 23
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.SaveUsingReflection(element, this, null, parameters);
 }
Ejemplo n.º 24
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.SaveUsingReflection(element, this, typeof(TestResultErrorInfo), parameters);
 }