public void Constructor_DatabaseWithValidSchema_ReturnsNewReader() { // Call using (var reader = new HydraRingSettingsDatabaseReader(completeDatabasePath)) { // Assert Assert.IsInstanceOf <SqLiteDatabaseReaderBase>(reader); } }
public void ReadExcludedPreprocessorLocations_EmptyTable_ReturnsEmptyEnumerable() { // Setup using (var reader = new HydraRingSettingsDatabaseReader(emptyDatabasePath)) { // Call IEnumerable <long> locations = reader.ReadExcludedPreprocessorLocations(); // Assert CollectionAssert.IsEmpty(locations); } }
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); } }
public void ReadExcludedPreprocessorLocations_InvalidValueInReadLocation_ThrowsCriticalFileReadException() { // Setup using (var reader = new HydraRingSettingsDatabaseReader(invalidDatabasePath)) { // Call TestDelegate test = () => reader.ReadExcludedPreprocessorLocations().ToArray(); // Assert Assert.Throws <CriticalFileReadException>(test); } }
public void ReadPreprocessorSetting_ValidLocationIdNotInDatabase_ReturnNull() { // Setup using (var reader = new HydraRingSettingsDatabaseReader(emptyDatabasePath)) { // Call ReadPreprocessorSetting preprocessorSetting = reader.ReadPreprocessorSetting(700131); // Assert Assert.IsNull(preprocessorSetting); } }
public void ReadTimeIntegrationSetting_EmptyTable_ReturnNull() { // Setup using (var reader = new HydraRingSettingsDatabaseReader(emptyDatabasePath)) { // Call TimeIntegrationSetting setting = reader.ReadTimeIntegrationSetting(700131, 0); // Assert Assert.IsNull(setting); } }
public void ReadNumericsSetting_EmptyTable_ReturnNull() { // Setup using (var reader = new HydraRingSettingsDatabaseReader(emptyDatabasePath)) { // Call NumericsSetting setting = reader.ReadNumericsSetting(700135, 101, 102); // Assert Assert.IsNull(setting); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
public void ReadExcludedPreprocessorLocations_TableWithRows_ReturnsAllLocationIdsInTable() { // Setup using (var reader = new HydraRingSettingsDatabaseReader(completeDatabasePath)) { // Call IEnumerable <long> locations = reader.ReadExcludedPreprocessorLocations(); // Assert CollectionAssert.AreEqual(new[] { 700136 }, locations); } }
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); } }
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)); } }
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))); } }
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); } }