Пример #1
0
        /// <summary>
        /// Obtains the Hydra-Ring settings based on the location and the failure mechanism obtained from the <paramref name="calculationInput"/>
        /// and sets these value on the <paramref name="calculationInput"/>.
        /// </summary>
        /// <param name="calculationInput">The calculation input for which the settings are updated.</param>
        /// <param name="hydraulicBoundaryDatabaseFilePath">The path to the hydraulic boundary database file.</param>
        /// <param name="usePreprocessor">Indicator whether to use the preprocessor in the calculation.</param>
        /// <exception cref="ArgumentException">Thrown when the <paramref name="hydraulicBoundaryDatabaseFilePath"/>
        /// contains invalid characters.</exception>
        /// <exception cref="CriticalFileReadException">Thrown when:
        /// <list type="bullet">
        /// <item>No settings database file could be found at the location of <paramref name="hydraulicBoundaryDatabaseFilePath"/>
        /// with the same name.</item>
        /// <item>Unable to open settings database file.</item>
        /// <item>Unable to read required data from database file.</item>
        /// </list>
        /// </exception>
        public static void AssignSettingsFromDatabase(HydraRingCalculationInput calculationInput, string hydraulicBoundaryDatabaseFilePath, bool usePreprocessor)
        {
            IOUtils.ValidateFilePath(hydraulicBoundaryDatabaseFilePath);

            long   locationId = calculationInput.HydraulicBoundaryLocationId;
            string settingsDatabaseFileName = HydraulicBoundaryDatabaseHelper.GetHydraulicBoundarySettingsDatabase(hydraulicBoundaryDatabaseFilePath);

            using (var preprocessorSettingsProvider = new PreprocessorSettingsProvider(settingsDatabaseFileName))
            {
                calculationInput.PreprocessorSetting = preprocessorSettingsProvider.GetPreprocessorSetting(locationId, usePreprocessor);
            }

            using (var designTablesSettingsProviders = new DesignTablesSettingsProvider(settingsDatabaseFileName))
            {
                calculationInput.DesignTablesSetting = designTablesSettingsProviders.GetDesignTablesSetting(
                    locationId,
                    calculationInput.FailureMechanismType);
            }

            using (var numericsSettingsProvider = new NumericsSettingsProvider(settingsDatabaseFileName))
            {
                calculationInput.NumericsSettings = numericsSettingsProvider.GetNumericsSettings(
                    locationId,
                    calculationInput.FailureMechanismType);
            }

            using (var timeIntegrationSettingsProvider = new TimeIntegrationSettingsProvider(settingsDatabaseFileName))
            {
                calculationInput.TimeIntegrationSetting = timeIntegrationSettingsProvider.GetTimeIntegrationSetting(
                    locationId,
                    calculationInput.FailureMechanismType);
            }
        }
Пример #2
0
 public void Constructor_ValidPath_ReturnsNewInstance()
 {
     // Call
     using (var provider = new DesignTablesSettingsProvider(completeDatabaseDataPath))
     {
         // Assert
         Assert.IsInstanceOf <IDisposable>(provider);
     }
 }
Пример #3
0
        public void GetDesignTablesSetting_FailureMechanismTypeIsInvalid_ThrowsInvalidEnumArgumentException()
        {
            // Setup
            using (var designTablesSettingsProvider = new DesignTablesSettingsProvider(completeDatabaseDataPath))
            {
                // Call
                TestDelegate test = () => designTablesSettingsProvider.GetDesignTablesSetting(0,
                                                                                              (HydraRingFailureMechanismType)4000);

                // Assert
                Assert.Throws <InvalidEnumArgumentException>(test);
            }
        }
Пример #4
0
        public void GetDesignTablesSetting_UnknownFailureMechanismTypeOrLocationId_ReturnsDefaultDesignTablesSetting(
            HydraRingFailureMechanismType failureMechanismType, long locationId, double expectedValueMin, double expectedValueMax)
        {
            // Setup
            using (var designTablesSettingsProvider = new DesignTablesSettingsProvider(completeDatabaseDataPath))
            {
                // Call
                DesignTablesSetting designTablesSetting = designTablesSettingsProvider.GetDesignTablesSetting(locationId, failureMechanismType);

                // Assert
                Assert.AreEqual(expectedValueMin, designTablesSetting.ValueMin);
                Assert.AreEqual(expectedValueMax, designTablesSetting.ValueMax);
            }
        }