/// <summary>
        /// Initializes a new instance of the <see cref="TestEnvironmentDescription"/> class.
        /// </summary>
        /// <param name="name">The name of the test environment.</param>
        /// <param name="operatingSystem">The operating system required for the test environment.</param>
        /// <param name="applications">The collection of applications that are required for the test environment.</param>
        public TestEnvironmentDescription(string name, OperatingSystemDescription operatingSystem, IEnumerable<ApplicationDescription> applications)
        {
            {
                Debug.Assert(!string.IsNullOrEmpty(name), "The name of the environment should not be an empty string.");
                Debug.Assert(operatingSystem != null, "The operating system should not be a null reference.");
                Debug.Assert(applications != null, "The collection of applications should not be a null reference.");
            }

            Name = name;
            OperatingSystem = operatingSystem;
            Applications = applications;
        }
Esempio n. 2
0
        private static XmlDocument GenerateEnvironmentDataStorage(
            OperatingSystemDescription operatingSystemDescription,
            IEnumerable<ApplicationDescription> applications)
        {
            var result = new XmlDocument();
            var rootNode = result.CreateElement("environment");
            result.AppendChild(rootNode);

            var operatingSystemNode = result.CreateElement("operatingsystem");
            rootNode.AppendChild(operatingSystemNode);

            // store the operating system information in the same way as was stored in
            // the original config file.
            {
                var nameAttribute = result.CreateAttribute("name");
                nameAttribute.Value = operatingSystemDescription.Name;
                operatingSystemNode.Attributes.Append(nameAttribute);

                var servicePackAttribute = result.CreateAttribute("servicepack");
                servicePackAttribute.Value = operatingSystemDescription.ServicePack;
                operatingSystemNode.Attributes.Append(servicePackAttribute);

                var cultureAttribute = result.CreateAttribute("culture");
                cultureAttribute.Value = operatingSystemDescription.Culture.Name;
                operatingSystemNode.Attributes.Append(cultureAttribute);

                var pointerSizeAttribute = result.CreateAttribute("architecturepointersize");
                pointerSizeAttribute.Value = operatingSystemDescription.PointerSize.ToString(CultureInfo.InvariantCulture);
                operatingSystemNode.Attributes.Append(pointerSizeAttribute);
            }

            var applicationsNode = result.CreateElement("applications");
            rootNode.AppendChild(applicationsNode);
            foreach (var application in applications)
            {
                var applicationNode = result.CreateElement("application");
                applicationsNode.AppendChild(applicationNode);

                var nameAttribute = result.CreateAttribute("name");
                nameAttribute.Value = application.Name;
                applicationNode.Attributes.Append(nameAttribute);

                var versionAttribute = result.CreateAttribute("version");
                versionAttribute.Value = application.Version.ToString(4);
                applicationNode.Attributes.Append(versionAttribute);
            }

            return result;
        }