Example #1
0
 public void Constructor_DatabaseWithValidSchema_ReturnsNewReader()
 {
     // Call
     using (var reader = new HydraRingSettingsDatabaseReader(completeDatabasePath))
     {
         // Assert
         Assert.IsInstanceOf <SqLiteDatabaseReaderBase>(reader);
     }
 }
Example #2
0
        public void ReadExcludedPreprocessorLocations_EmptyTable_ReturnsEmptyEnumerable()
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(emptyDatabasePath))
            {
                // Call
                IEnumerable <long> locations = reader.ReadExcludedPreprocessorLocations();

                // Assert
                CollectionAssert.IsEmpty(locations);
            }
        }
Example #3
0
        public void ReadTimeIntegrationSetting_InvalidValueInReadLocation_ThrowsCriticalFileReadException()
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(invalidDatabasePath))
            {
                // Call
                TestDelegate test = () => reader.ReadTimeIntegrationSetting(700131, HydraRingFailureMechanismType.AssessmentLevel);

                // Assert
                Assert.Throws <CriticalFileReadException>(test);
            }
        }
Example #4
0
        public void ReadExcludedPreprocessorLocations_InvalidValueInReadLocation_ThrowsCriticalFileReadException()
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(invalidDatabasePath))
            {
                // Call
                TestDelegate test = () => reader.ReadExcludedPreprocessorLocations().ToArray();

                // Assert
                Assert.Throws <CriticalFileReadException>(test);
            }
        }
Example #5
0
        public void ReadPreprocessorSetting_ValidLocationIdNotInDatabase_ReturnNull()
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(emptyDatabasePath))
            {
                // Call
                ReadPreprocessorSetting preprocessorSetting = reader.ReadPreprocessorSetting(700131);

                // Assert
                Assert.IsNull(preprocessorSetting);
            }
        }
Example #6
0
        public void ReadTimeIntegrationSetting_EmptyTable_ReturnNull()
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(emptyDatabasePath))
            {
                // Call
                TimeIntegrationSetting setting = reader.ReadTimeIntegrationSetting(700131, 0);

                // Assert
                Assert.IsNull(setting);
            }
        }
Example #7
0
        public void ReadNumericsSetting_EmptyTable_ReturnNull()
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(emptyDatabasePath))
            {
                // Call
                NumericsSetting setting = reader.ReadNumericsSetting(700135, 101, 102);

                // Assert
                Assert.IsNull(setting);
            }
        }
Example #8
0
        public void ReadTimeIntegrationSetting_ValidLocationIdAndFailureMechanismTypeNotInDatabase_ReturnNull(long locationId, HydraRingFailureMechanismType calculationType)
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(completeDatabasePath))
            {
                // Call
                TimeIntegrationSetting setting = reader.ReadTimeIntegrationSetting(locationId, calculationType);

                // Assert
                Assert.IsNull(setting);
            }
        }
Example #9
0
        public void ReadDesignTableSetting_InvalidFailureMechanismType_ThrowsInvalidEnumArgumentException(HydraRingFailureMechanismType calculationType)
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(completeDatabasePath))
            {
                // Call
                TestDelegate test = () => reader.ReadDesignTableSetting(123, calculationType);

                // Assert
                Assert.Throws <InvalidEnumArgumentException>(test);
            }
        }
Example #10
0
        public void ReadDesignTableSetting_InvalidValueInReadLocation_ThrowsCriticalFileReadException(long locationId, HydraRingFailureMechanismType type)
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(invalidDatabasePath))
            {
                // Call
                TestDelegate test = () => reader.ReadDesignTableSetting(locationId, type);

                // Assert
                Assert.Throws <CriticalFileReadException>(test);
            }
        }
Example #11
0
        public void ReadNumericsSetting_InvalidValueInReadLocation_ThrowsCriticalFileReadException(
            long locationId, int mechanismId, int subMechanismId)
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(invalidDatabasePath))
            {
                // Call
                TestDelegate test = () => reader.ReadNumericsSetting(locationId, mechanismId, subMechanismId);

                // Assert
                Assert.Throws <CriticalFileReadException>(test);
            }
        }
Example #12
0
        public void ReadNumericsSetting_ValidLocationIdFailureMechanismTypeAndSubMechanismIdNotInDatabase_ReturnNull(
            long locationId, int mechanismId, int subMechanismId)
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(completeDatabasePath))
            {
                // Call
                NumericsSetting setting = reader.ReadNumericsSetting(locationId, mechanismId, subMechanismId);

                // Assert
                Assert.IsNull(setting);
            }
        }
Example #13
0
        public void ReadTimeIntegrationSetting_ValidLocationIdAndFailureMechanismType_TimeIntegrationSettingWithExpectedValues(
            long locationId, HydraRingFailureMechanismType calculationType, int expectedTimeIntegrationScheme)
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(completeDatabasePath))
            {
                // Call
                TimeIntegrationSetting setting = reader.ReadTimeIntegrationSetting(locationId, calculationType);

                // Assert
                Assert.AreEqual(expectedTimeIntegrationScheme, setting.TimeIntegrationSchemeId);
            }
        }
Example #14
0
        public void ReadDesignTableSetting_ValidLocationIdAndFailureMechanismType_DesignTableSettingWithExpectedValues(
            long locationId, HydraRingFailureMechanismType calculationType, double expectedMin, double expectedMax)
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(completeDatabasePath))
            {
                // Call
                DesignTablesSetting setting = reader.ReadDesignTableSetting(locationId, calculationType);

                // Assert
                Assert.AreEqual(expectedMin, setting.ValueMin);
                Assert.AreEqual(expectedMax, setting.ValueMax);
            }
        }
Example #15
0
        public void ReadExcludedPreprocessorLocations_TableWithRows_ReturnsAllLocationIdsInTable()
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(completeDatabasePath))
            {
                // Call
                IEnumerable <long> locations = reader.ReadExcludedPreprocessorLocations();

                // Assert
                CollectionAssert.AreEqual(new[]
                {
                    700136
                }, locations);
            }
        }
Example #16
0
        public void ReadPreprocessorSetting_ValidLocationId_ReadPreprocessorSettingWithExpectedValues(long locationId,
                                                                                                      double valueMin,
                                                                                                      double valueMax)
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(completeDatabasePath))
            {
                // Call
                ReadPreprocessorSetting preprocessorSetting = reader.ReadPreprocessorSetting(locationId);

                // Assert
                Assert.AreEqual(valueMin, preprocessorSetting.ValueMin);
                Assert.AreEqual(valueMax, preprocessorSetting.ValueMax);
            }
        }
Example #17
0
 private ReadResult <IEnumerable <long> > ReadExcludedLocations(HydraRingSettingsDatabaseReader reader)
 {
     try
     {
         return(new ReadResult <IEnumerable <long> >(false)
         {
             Items = new[]
             {
                 reader.ReadExcludedLocations().ToArray()
             }
         });
     }
     catch (CriticalFileReadException e)
     {
         return(HandleCriticalFileReadError <IEnumerable <long> >(e.Message));
     }
 }
Example #18
0
        private ReadResult <IEnumerable <long> > ReadExcludedLocations()
        {
            NotifyProgress(Resources.HydraulicBoundaryDatabaseImporter_ProgressText_Reading_HRD_settings_file, 3, numberOfSteps);
            string settingsFilePath = HydraulicBoundaryDatabaseHelper.GetHydraulicBoundarySettingsDatabase(FilePath);

            try
            {
                using (var reader = new HydraRingSettingsDatabaseReader(settingsFilePath))
                {
                    return(ReadExcludedLocations(reader));
                }
            }
            catch (CriticalFileReadException e)
            {
                return(HandleCriticalFileReadError <IEnumerable <long> >(
                           string.Format(Resources.HydraulicBoundaryDatabaseImporter_Cannot_open_hydraulic_calculation_settings_file_0_, e.Message)));
            }
        }
Example #19
0
        public void ReadNumericsSetting_ValidLocationIdAndFailureMechanismType_NumericsSettingWithExpectedValues(
            long locationId,
            int mechanismId,
            int subMechanismId,
            int expectedCalculationTechniqueId,
            int expectedFormStartMethod,
            int expectedFormNumberOfIterations,
            double expectedFormRelaxationFactor,
            double expectedFormEpsBeta,
            double expectedFormEpsHoh,
            double expectedFormEpsZFunc,
            int expectedDsStartMethod,
            int expectedDsMinNumberOfIterations,
            int expectedDsMaxNumberOfIterations,
            double expectedDsVarCoefficient,
            double expectedNiUMin,
            double expectedNiUMax,
            int expectedNiNumberSteps)
        {
            // Setup
            using (var reader = new HydraRingSettingsDatabaseReader(completeDatabasePath))
            {
                // Call
                NumericsSetting setting = reader.ReadNumericsSetting(locationId, mechanismId, subMechanismId);

                // Assert
                Assert.AreEqual(expectedCalculationTechniqueId, setting.CalculationTechniqueId);
                Assert.AreEqual(expectedFormStartMethod, setting.FormStartMethod);
                Assert.AreEqual(expectedFormNumberOfIterations, setting.FormNumberOfIterations);
                Assert.AreEqual(expectedFormRelaxationFactor, setting.FormRelaxationFactor);
                Assert.AreEqual(expectedFormEpsBeta, setting.FormEpsBeta);
                Assert.AreEqual(expectedFormEpsHoh, setting.FormEpsHoh);
                Assert.AreEqual(expectedFormEpsZFunc, setting.FormEpsZFunc);
                Assert.AreEqual(expectedDsStartMethod, setting.DsStartMethod);
                Assert.AreEqual(expectedDsMinNumberOfIterations, setting.DsMinNumberOfIterations);
                Assert.AreEqual(expectedDsMaxNumberOfIterations, setting.DsMaxNumberOfIterations);
                Assert.AreEqual(expectedDsVarCoefficient, setting.DsVarCoefficient);
                Assert.AreEqual(expectedNiUMin, setting.NiUMin);
                Assert.AreEqual(expectedNiUMax, setting.NiUMax);
                Assert.AreEqual(expectedNiNumberSteps, setting.NiNumberSteps);
            }
        }