public void GenerateInitializationScript_ReturnsExpectedInitializationScript(
            [Values("", "D:\\preprocessor")] string preprocessorDirectory,
            [Values(true, false)] bool usePreprocessorClosure)
        {
            // Setup
            const string hlcdFilePath = "D:\\hlcd\\HlcdFile.sqlite";

            var settings = new HydraRingCalculationSettings(hlcdFilePath, preprocessorDirectory, usePreprocessorClosure);
            var hydraRingInitializationService = new HydraRingInitializationService(HydraRingFailureMechanismType.StructuresStructuralFailure,
                                                                                    700001,
                                                                                    TestHelper.GetScratchPadPath(),
                                                                                    settings);

            string expectedInitializationScript = "section                 = 700001" + Environment.NewLine +
                                                  "mechanism               = 112" + Environment.NewLine +
                                                  "alternative             = 1" + Environment.NewLine +
                                                  "layer                   = 1" + Environment.NewLine +
                                                  "logfile                 = 700001.log" + Environment.NewLine +
                                                  "outputverbosity         = basic" + Environment.NewLine +
                                                  "outputtofile            = file" + Environment.NewLine +
                                                  "projectdbfilename       = 700001.sql" + Environment.NewLine +
                                                  "outputfilename          = designTable.txt" + Environment.NewLine +
                                                  "configdbfilename        = " + Path.Combine(hydraRingDirectory, "config.sqlite") + Environment.NewLine +
                                                  "hydraulicdbfilename     = " + hlcdFilePath + Environment.NewLine +
                                                  "designpointOutput       = sqlite";

            if (preprocessorDirectory != string.Empty)
            {
                expectedInitializationScript += Environment.NewLine + "preprocessordbdirectory = " + preprocessorDirectory;
            }

            if (usePreprocessorClosure)
            {
                expectedInitializationScript += Environment.NewLine + "preprocessorclosingdbfilename = D:\\hlcd\\HlcdFile_preprocClosure.sqlite";
            }

            try
            {
                // Call
                hydraRingInitializationService.WriteInitializationScript();

                // Assert
                string initializationScript = File.ReadAllText(hydraRingInitializationService.IniFilePath);
                Assert.AreEqual(expectedInitializationScript, initializationScript);
            }
            finally
            {
                File.Delete(hydraRingInitializationService.IniFilePath);
            }
        }
        /// <summary>
        /// Performs the actual calculation by running the Hydra-Ring executable.
        /// </summary>
        /// <param name="uncertaintiesType">The uncertainty type used in the calculation.</param>
        /// <param name="hydraRingCalculationInput">The object containing input data.</param>
        /// <exception cref="HydraRingCalculationException">Thrown when an error occurs while performing the calculation.</exception>
        /// <exception cref="InvalidOperationException">Thrown when preprocessor directory is required but not specified.</exception>
        protected void Calculate(HydraRingUncertaintiesType uncertaintiesType,
                                 HydraRingCalculationInput hydraRingCalculationInput)
        {
            try
            {
                if (string.IsNullOrEmpty(calculationSettings.PreprocessorDirectory) && hydraRingCalculationInput.PreprocessorSetting.RunPreprocessor)
                {
                    throw new InvalidOperationException("Preprocessor directory required but not specified.");
                }

                int sectionId = hydraRingCalculationInput.Section.SectionId;
                OutputDirectory = CreateWorkingDirectory();

                var hydraRingConfigurationService = new HydraRingConfigurationService(uncertaintiesType);
                hydraRingConfigurationService.AddHydraRingCalculationInput(hydraRingCalculationInput);

                var hydraRingInitializationService = new HydraRingInitializationService(
                    hydraRingCalculationInput.FailureMechanismType,
                    sectionId,
                    OutputDirectory,
                    calculationSettings);
                hydraRingInitializationService.WriteInitializationScript();
                hydraRingConfigurationService.WriteDatabaseCreationScript(hydraRingInitializationService.DatabaseCreationScriptFilePath);

                PerformCalculation(OutputDirectory, hydraRingInitializationService);
                ExecuteGenericParsers(hydraRingInitializationService, sectionId);
                ExecuteCustomParsers(hydraRingInitializationService.TemporaryWorkingDirectory, sectionId);
            }
            catch (HydraRingFileParserException e)
            {
                throw new HydraRingCalculationException(e.Message, e.InnerException);
            }
            catch (Exception e) when(IsSupportedCalculatedException(e))
            {
                throw new HydraRingCalculationException(string.Format(Resources.HydraRingCalculatorBase_Calculate_Critical_error_during_calculation_Exception_0,
                                                                      e.Message),
                                                        e.InnerException);
            }
        }