Пример #1
0
        /// <summary>
        /// Initialize a configuration with given parameters.
        /// </summary>
        /// <param name="server"></param>
        /// <param name="project"></param>
        /// <param name="filename"></param>
        /// <param name="templateName"></param>
        /// <param name="overwrite"></param>
        /// <param name="closeOnFinish"></param>
        /// <param name="configFile"></param>
        /// <param name="wordHidden"></param>
        /// <param name="wordTemplateFile"></param>
        public DocumentConfiguration(string server, string project, string filename, string templateName, bool overwrite, bool closeOnFinish, string configFile, bool wordHidden, string wordTemplateFile, TraceLevel debugLevel)
        {
            Settings = new Settings();
            // Check that either XML-file or the settings-arguments are specified
            if ((server != null || project != null || filename != null || templateName != null || overwrite || closeOnFinish) && configFile != null)
            {
                throw new ArgumentException(Resources.CommandArgumentsError);
            }

            // Read settings from XML-file
            if (configFile != null)
            {
                try
                {
                    ReadConfigurationFile(configFile);

                    // Check for the basic settings and add them
                    if (_configuration.Settings == null)
                    {
                        throw new ArgumentException(string.Format(Resources.ConfigurationFileMisconfigured, "Settings"));
                    }

                    Settings = _configuration.Settings;


                    // Check for the TestSpec Settings and add them if they exist
                    if (_configuration.TestConfiguration != null && _configuration.TestConfiguration.TestSpecificationConfiguration != null)
                    {
                        TestSpecSettings = _configuration.TestConfiguration.TestSpecificationConfiguration;

                        if (TestSpecSettings.TestSuite == null)
                        {
                            TestSpecSettings.TestSuite = TestSpecSettings.TestPlan;
                        }

                        TestResultSettings = _configuration.TestConfiguration.TestResultConfiguration;
                    }

                    // Check for the TestResultSettings and add them if they exist
                    if (_configuration.TestConfiguration != null && _configuration.TestConfiguration.TestResultConfiguration != null)
                    {
                        // Default-Werte für nicht konfigurierte (optionale) Felder setzen
                        if (TestResultSettings.TestSuite == null)
                        {
                            TestResultSettings.TestSuite = TestResultSettings.TestPlan;
                        }

                        if (TestResultSettings.Build == null)
                        {
                            TestResultSettings.Build = "All";
                        }

                        if (TestResultSettings.TestConfiguration == null)
                        {
                            TestResultSettings.TestConfiguration = "All";
                        }
                    }
                }
                catch (ArgumentException e)
                {
                    // ReSharper disable once PossibleIntendedRethrow
                    throw e;
                }
            }
            // Read settings from commandline
            else
            {
                try
                {
                    Settings = ReadConsoleArguments(server, project, filename, templateName, overwrite, closeOnFinish, wordHidden, wordTemplateFile, debugLevel);
                }
                catch (Exception e)
                {
                    // ReSharper disable once PossibleIntendedRethrow
                    throw e;
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TestConfiguration"/> class.
 /// </summary>
 public TestConfiguration()
 {
     TestSpecificationConfiguration = new TestSpecSettings();
 }