public void SetValues_ScopeNull_ThrowsArgumentNullException()
        {
            // Setup
            var          random         = new Random(21);
            const string filePath       = "FilePath";
            const string scenarioName   = "ScenarioName";
            int          year           = random.Next();
            const string seaLevel       = "SeaLevel";
            const string riverDischarge = "RiverDischarge";
            const string lakeLevel      = "LakeLevel";
            const string windDirection  = "WindDirection";
            const string windSpeed      = "WindSpeed";
            const string comment        = "Comment";

            var settings = new HydraulicLocationConfigurationSettings();

            // Call
            TestDelegate call = () => settings.SetValues(filePath, scenarioName, year, null, false,
                                                         seaLevel, riverDischarge, lakeLevel,
                                                         windDirection, windSpeed, comment);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(call);

            Assert.AreEqual("scope", exception.ParamName);
        }
        public void SetValues_InvalidFilePathNull_ThrowsArgumentException(string invalidFilePath)
        {
            // Setup
            var          random         = new Random(21);
            const string scenarioName   = "FilePath";
            int          year           = random.Next();
            const string scope          = "Scope";
            const string seaLevel       = "SeaLevel";
            const string riverDischarge = "RiverDischarge";
            const string lakeLevel      = "LakeLevel";
            const string windDirection  = "WindDirection";
            const string windSpeed      = "WindSpeed";
            const string comment        = "Comment";

            var settings = new HydraulicLocationConfigurationSettings();

            // Call
            TestDelegate call = () => settings.SetValues(null, scenarioName, year, scope, false,
                                                         seaLevel, riverDischarge, lakeLevel,
                                                         windDirection, windSpeed, comment);

            // Assert
            const string expectedMessage = "'filePath' is null, empty or consists of whitespace.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(call, expectedMessage);
        }
        public void GetProperties_WithLinkedDatabase_ReturnsExpectedValues()
        {
            // Setup
            var mocks         = new MockRepository();
            var importHandler = mocks.Stub <IHydraulicLocationConfigurationDatabaseImportHandler>();

            mocks.ReplayAll();

            HydraulicBoundaryDatabase hydraulicBoundaryDatabase = CreateLinkedHydraulicBoundaryDatabase();

            // Precondition
            Assert.IsTrue(hydraulicBoundaryDatabase.IsLinked());

            // Call
            var properties = new HydraulicBoundaryDatabaseProperties(hydraulicBoundaryDatabase, importHandler);

            // Assert
            Assert.AreEqual(hydraulicBoundaryDatabase.FilePath, properties.HrdFilePath);

            HydraulicLocationConfigurationSettings configurationSettings = hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings;

            Assert.AreEqual(configurationSettings.FilePath, properties.HlcdFilePath);
            Assert.AreEqual(configurationSettings.FilePath, properties.HlcdFilePathReadOnly);
            Assert.AreEqual(configurationSettings.UsePreprocessorClosure, properties.UsePreprocessorClosure);
            Assert.AreEqual(configurationSettings.ScenarioName, properties.ScenarioName);
            Assert.AreEqual(configurationSettings.Year.ToString(), properties.Year);
            Assert.AreEqual(configurationSettings.Scope, properties.Scope);
            Assert.AreEqual(configurationSettings.SeaLevel, properties.SeaLevel);
            Assert.AreEqual(configurationSettings.RiverDischarge, properties.RiverDischarge);
            Assert.AreEqual(configurationSettings.LakeLevel, properties.LakeLevel);
            Assert.AreEqual(configurationSettings.WindDirection, properties.WindDirection);
            Assert.AreEqual(configurationSettings.WindSpeed, properties.WindSpeed);
            Assert.AreEqual(configurationSettings.Comment, properties.Comment);
            mocks.VerifyAll();
        }
        public void SetValues_OptionalArgumentsNull_SetsExpectedValues()
        {
            // Setup
            var          random                 = new Random(21);
            const string filePath               = "FilePath";
            const string scenarioName           = "ScenarioName";
            int          year                   = random.Next();
            const string scope                  = "Scope";
            bool         usePreprocessorClosure = random.NextBoolean();

            var settings = new HydraulicLocationConfigurationSettings();

            // Call
            settings.SetValues(filePath, scenarioName, year, scope,
                               usePreprocessorClosure,
                               null, null, null, null, null, null);

            // Assert
            Assert.AreEqual(filePath, settings.FilePath);
            Assert.AreEqual(scenarioName, settings.ScenarioName);
            Assert.AreEqual(year, settings.Year);
            Assert.AreEqual(scope, settings.Scope);
            Assert.AreEqual(usePreprocessorClosure, settings.UsePreprocessorClosure);

            Assert.IsNull(settings.SeaLevel);
            Assert.IsNull(settings.RiverDischarge);
            Assert.IsNull(settings.LakeLevel);
            Assert.IsNull(settings.WindDirection);
            Assert.IsNull(settings.WindSpeed);
            Assert.IsNull(settings.Comment);
        }
        /// <summary>
        /// Creates a <see cref="HydraulicBoundaryDatabaseEntity"/> based on the information of the
        /// <see cref="HydraulicBoundaryDatabase"/>.
        /// </summary>
        /// <param name="hydraulicBoundaryDatabase">The <see cref="HydraulicBoundaryDatabase"/> to create a
        /// <see cref="HydraulicBoundaryDatabaseEntity"/> for.</param>
        /// <returns>A new <see cref="HydraulicBoundaryDatabaseEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="hydraulicBoundaryDatabase"/>
        /// is <c>null</c>.</exception>
        internal static HydraulicBoundaryDatabaseEntity Create(this HydraulicBoundaryDatabase hydraulicBoundaryDatabase)
        {
            if (hydraulicBoundaryDatabase == null)
            {
                throw new ArgumentNullException(nameof(hydraulicBoundaryDatabase));
            }

            HydraulicLocationConfigurationSettings settings = hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings;

            return(new HydraulicBoundaryDatabaseEntity
            {
                FilePath = hydraulicBoundaryDatabase.FilePath.DeepClone(),
                Version = hydraulicBoundaryDatabase.Version.DeepClone(),
                HydraulicLocationConfigurationSettingsFilePath = settings.FilePath.DeepClone(),
                HydraulicLocationConfigurationSettingsUsePreprocessorClosure = Convert.ToByte(settings.UsePreprocessorClosure),
                HydraulicLocationConfigurationSettingsScenarioName = settings.ScenarioName.DeepClone(),
                HydraulicLocationConfigurationSettingsYear = settings.Year,
                HydraulicLocationConfigurationSettingsScope = settings.Scope.DeepClone(),
                HydraulicLocationConfigurationSettingsSeaLevel = settings.SeaLevel.DeepClone(),
                HydraulicLocationConfigurationSettingsRiverDischarge = settings.RiverDischarge.DeepClone(),
                HydraulicLocationConfigurationSettingsLakeLevel = settings.LakeLevel.DeepClone(),
                HydraulicLocationConfigurationSettingsWindDirection = settings.WindDirection.DeepClone(),
                HydraulicLocationConfigurationSettingsWindSpeed = settings.WindSpeed.DeepClone(),
                HydraulicLocationConfigurationSettingsComment = settings.Comment.DeepClone()
            });
        }
        public void SetHydraulicLocationConfigurationSettings_ReadHydraulicLocationConfigurationDatabaseSettingsNotNull_SetExpectedValuesAndDoesNotLog()
        {
            // Setup
            const string filePath = "some/file/path";
            var          settings = new HydraulicLocationConfigurationSettings();
            ReadHydraulicLocationConfigurationDatabaseSettings readSettings = ReadHydraulicLocationConfigurationDatabaseSettingsTestFactory.Create();
            bool usePreprocessorClosure = new Random(21).NextBoolean();

            // Call
            Action call = () => HydraulicLocationConfigurationSettingsUpdateHelper.SetHydraulicLocationConfigurationSettings(
                settings, readSettings, usePreprocessorClosure, filePath);

            // Assert
            TestHelper.AssertLogMessagesCount(call, 0);

            Assert.AreEqual(filePath, settings.FilePath);
            Assert.AreEqual(readSettings.ScenarioName, settings.ScenarioName);
            Assert.AreEqual(readSettings.Year, settings.Year);
            Assert.AreEqual(readSettings.Scope, settings.Scope);
            Assert.AreEqual(usePreprocessorClosure, settings.UsePreprocessorClosure);
            Assert.AreEqual(readSettings.SeaLevel, settings.SeaLevel);
            Assert.AreEqual(readSettings.RiverDischarge, settings.RiverDischarge);
            Assert.AreEqual(readSettings.LakeLevel, settings.LakeLevel);
            Assert.AreEqual(readSettings.WindDirection, settings.WindDirection);
            Assert.AreEqual(readSettings.WindSpeed, settings.WindSpeed);
            Assert.AreEqual(readSettings.Comment, settings.Comment);
        }
        public void Update_ReadHydraulicLocationConfigurationDatabaseSettingsNull_SetsDefaultValuesAndLogsWarning()
        {
            // Setup
            const string hlcdFilePath = "some/file/path";
            var          handler      = new HydraulicLocationConfigurationDatabaseUpdateHandler(CreateAssessmentSection());
            var          hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
            bool         usePreprocessorClosure    = new Random(21).NextBoolean();

            // Call
            void Call() => handler.Update(hydraulicBoundaryDatabase, null, usePreprocessorClosure, hlcdFilePath);

            // Assert
            const string expectedMessage = "De tabel 'ScenarioInformation' in het HLCD bestand is niet aanwezig. Er worden standaardwaarden " +
                                           "conform WBI2017 gebruikt voor de HLCD bestandsinformatie.";

            TestHelper.AssertLogMessageWithLevelIsGenerated(Call, Tuple.Create(expectedMessage, LogLevelConstant.Warn), 1);

            HydraulicLocationConfigurationSettings settings = hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings;

            Assert.AreEqual(hlcdFilePath, settings.FilePath);
            Assert.AreEqual("WBI2017", settings.ScenarioName);
            Assert.AreEqual(2023, settings.Year);
            Assert.AreEqual("WBI2017", settings.Scope);
            Assert.AreEqual(usePreprocessorClosure, settings.UsePreprocessorClosure);
            Assert.AreEqual("Conform WBI2017", settings.SeaLevel);
            Assert.AreEqual("Conform WBI2017", settings.RiverDischarge);
            Assert.AreEqual("Conform WBI2017", settings.LakeLevel);
            Assert.AreEqual("Conform WBI2017", settings.WindDirection);
            Assert.AreEqual("Conform WBI2017", settings.WindSpeed);
            Assert.AreEqual("Gegenereerd door Riskeer (conform WBI2017)", settings.Comment);
        }
        public void Update_WithReadHydraulicLocationConfigurationDatabaseSettings_SetsExpectedValuesAndDoesNotLog()
        {
            // Setup
            const string hlcdFilePath = "some/file/path";
            var          handler      = new HydraulicLocationConfigurationDatabaseUpdateHandler(CreateAssessmentSection());
            var          hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
            ReadHydraulicLocationConfigurationDatabaseSettings readSettings = ReadHydraulicLocationConfigurationDatabaseSettingsTestFactory.Create();
            bool usePreprocessorClosure = new Random(21).NextBoolean();

            // Call
            void Call() => handler.Update(hydraulicBoundaryDatabase, readSettings, usePreprocessorClosure, hlcdFilePath);

            // Assert
            TestHelper.AssertLogMessagesCount(Call, 0);

            HydraulicLocationConfigurationSettings settings = hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings;

            Assert.AreEqual(hlcdFilePath, settings.FilePath);
            Assert.AreEqual(readSettings.ScenarioName, settings.ScenarioName);
            Assert.AreEqual(readSettings.Year, settings.Year);
            Assert.AreEqual(readSettings.Scope, settings.Scope);
            Assert.AreEqual(usePreprocessorClosure, settings.UsePreprocessorClosure);
            Assert.AreEqual(readSettings.SeaLevel, settings.SeaLevel);
            Assert.AreEqual(readSettings.RiverDischarge, settings.RiverDischarge);
            Assert.AreEqual(readSettings.LakeLevel, settings.LakeLevel);
            Assert.AreEqual(readSettings.WindDirection, settings.WindDirection);
            Assert.AreEqual(readSettings.WindSpeed, settings.WindSpeed);
            Assert.AreEqual(readSettings.Comment, settings.Comment);
        }
        public void PreprocessorDirectory_SetValidValueWithCanUsePreprocessorFalse_ThrowsInvalidOperationException()
        {
            // Setup
            var settings = new HydraulicLocationConfigurationSettings();

            // Call
            TestDelegate test = () => settings.PreprocessorDirectory = "Preprocessor";

            // Assert
            string message = Assert.Throws <InvalidOperationException>(test).Message;

            Assert.AreEqual($"{nameof(HydraulicLocationConfigurationSettings.CanUsePreprocessor)} is false.", message);
        }
        public void CanUsePreprocessor_Always_ExpectedValuesSet(bool canUsePreprocessor)
        {
            // Setup
            var settings = new HydraulicLocationConfigurationSettings();

            // Call
            settings.CanUsePreprocessor = canUsePreprocessor;

            // Assert
            Assert.AreEqual(canUsePreprocessor, settings.CanUsePreprocessor);
            Assert.IsFalse(settings.UsePreprocessor);
            Assert.IsNull(settings.PreprocessorDirectory);
        }
        public void UsePreprocessor_SetValueWithCanUsePreprocessorFalse_ThrowsInvalidOperationException()
        {
            // Setup
            bool usePreprocessor = new Random(11).NextBoolean();
            var  settings        = new HydraulicLocationConfigurationSettings();

            // Call
            TestDelegate test = () => settings.UsePreprocessor = usePreprocessor;

            // Assert
            string message = Assert.Throws <InvalidOperationException>(test).Message;

            Assert.AreEqual($"{nameof(HydraulicLocationConfigurationSettings.CanUsePreprocessor)} is false.", message);
        }
        public void PreprocessorDirectory_SetValidValueWithCanUsePreprocessorTrue_ExpectedValueSet()
        {
            // Setup
            const string preprocessorDirectory = "OtherPreprocessor";
            var          settings = new HydraulicLocationConfigurationSettings
            {
                CanUsePreprocessor = true
            };

            // Call
            settings.PreprocessorDirectory = preprocessorDirectory;

            // Assert
            Assert.AreEqual(preprocessorDirectory, settings.PreprocessorDirectory);
        }
        public void UsePreprocessor_SetValueWithCanUsePreprocessorTrue_ExpectedValueSet()
        {
            // Setup
            bool usePreprocessor = new Random(11).NextBoolean();
            var  settings        = new HydraulicLocationConfigurationSettings
            {
                CanUsePreprocessor = true
            };

            // Call
            settings.UsePreprocessor = usePreprocessor;

            // Assert
            Assert.AreEqual(usePreprocessor, settings.UsePreprocessor);
        }
Example #14
0
        /// <summary>
        /// Sets the hydraulic location configuration settings.
        /// </summary>
        /// <param name="hydraulicLocationConfigurationSettings">The hydraulic location configuration settings to set on.</param>
        /// <param name="readHydraulicLocationConfigurationDatabaseSettings">The read settings to set.</param>
        /// <param name="usePreprocessorClosure">Indicator whether to use the preprocessor closure.</param>
        /// <param name="hlcdFilePath">The hlcd file path.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="hydraulicLocationConfigurationSettings"/>
        /// or <paramref name="hlcdFilePath"/> is <c>null</c>.</exception>
        public static void SetHydraulicLocationConfigurationSettings(HydraulicLocationConfigurationSettings hydraulicLocationConfigurationSettings,
                                                                     ReadHydraulicLocationConfigurationDatabaseSettings readHydraulicLocationConfigurationDatabaseSettings,
                                                                     bool usePreprocessorClosure,
                                                                     string hlcdFilePath)
        {
            if (hydraulicLocationConfigurationSettings == null)
            {
                throw new ArgumentNullException(nameof(hydraulicLocationConfigurationSettings));
            }

            if (hlcdFilePath == null)
            {
                throw new ArgumentNullException(nameof(hlcdFilePath));
            }

            if (readHydraulicLocationConfigurationDatabaseSettings != null)
            {
                hydraulicLocationConfigurationSettings.SetValues(
                    hlcdFilePath,
                    readHydraulicLocationConfigurationDatabaseSettings.ScenarioName,
                    readHydraulicLocationConfigurationDatabaseSettings.Year,
                    readHydraulicLocationConfigurationDatabaseSettings.Scope,
                    usePreprocessorClosure,
                    readHydraulicLocationConfigurationDatabaseSettings.SeaLevel,
                    readHydraulicLocationConfigurationDatabaseSettings.RiverDischarge,
                    readHydraulicLocationConfigurationDatabaseSettings.LakeLevel,
                    readHydraulicLocationConfigurationDatabaseSettings.WindDirection,
                    readHydraulicLocationConfigurationDatabaseSettings.WindSpeed,
                    readHydraulicLocationConfigurationDatabaseSettings.Comment);
            }
            else
            {
                log.Warn(Resources.HydraulicLocationConfigurationSettingsUpdateHelper_ReadHydraulicLocationConfigurationDatabaseSettings_No_ScenarioInformation_entries_present);

                hydraulicLocationConfigurationSettings.SetValues(
                    hlcdFilePath,
                    HydraulicLocationConfigurationSettingsConstants.MandatoryConfigurationPropertyDefaultValue,
                    HydraulicLocationConfigurationSettingsConstants.YearDefaultValue,
                    HydraulicLocationConfigurationSettingsConstants.MandatoryConfigurationPropertyDefaultValue,
                    usePreprocessorClosure,
                    HydraulicLocationConfigurationSettingsConstants.OptionalConfigurationPropertyDefaultValue,
                    HydraulicLocationConfigurationSettingsConstants.OptionalConfigurationPropertyDefaultValue,
                    HydraulicLocationConfigurationSettingsConstants.OptionalConfigurationPropertyDefaultValue,
                    HydraulicLocationConfigurationSettingsConstants.OptionalConfigurationPropertyDefaultValue,
                    HydraulicLocationConfigurationSettingsConstants.OptionalConfigurationPropertyDefaultValue,
                    HydraulicLocationConfigurationSettingsConstants.AdditionalInformationConfigurationPropertyValue);
            }
        }
        public void PreprocessorDirectory_SetInvalidValueWithCanUsePreprocessorTrue_ThrowsArgumentException(string preprocessorDirectory)
        {
            // Setup
            var settings = new HydraulicLocationConfigurationSettings
            {
                CanUsePreprocessor = true
            };

            // Call
            TestDelegate test = () => settings.PreprocessorDirectory = preprocessorDirectory;

            // Assert
            string message = Assert.Throws <ArgumentException>(test).Message;

            Assert.AreEqual("De bestandsmap waar de preprocessor bestanden opslaat moet een waarde hebben.", message);
        }
Example #16
0
        public void Read_WithValidEntity_UpdatesHydraulicBoundaryDatabase()
        {
            // Setup
            var  random = new Random(21);
            bool usePreprocessorClosure = random.NextBoolean();
            var  entity = new HydraulicBoundaryDatabaseEntity
            {
                FilePath = "hydraulicBoundaryDatabaseFilePath",
                Version  = "hydraulicBoundaryDatabaseVersion",
                HydraulicLocationConfigurationSettingsFilePath = "hlcdFilePath",
                HydraulicLocationConfigurationSettingsUsePreprocessorClosure = Convert.ToByte(usePreprocessorClosure),
                HydraulicLocationConfigurationSettingsScenarioName           = "ScenarioName",
                HydraulicLocationConfigurationSettingsYear           = random.Next(),
                HydraulicLocationConfigurationSettingsScope          = "Scope",
                HydraulicLocationConfigurationSettingsSeaLevel       = "SeaLevel",
                HydraulicLocationConfigurationSettingsRiverDischarge = "RiverDischarge",
                HydraulicLocationConfigurationSettingsLakeLevel      = "LakeLevel",
                HydraulicLocationConfigurationSettingsWindDirection  = "WindDirection",
                HydraulicLocationConfigurationSettingsWindSpeed      = "WindSpeed",
                HydraulicLocationConfigurationSettingsComment        = "Comment"
            };

            var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();

            // Call
            entity.Read(hydraulicBoundaryDatabase);

            // Assert
            Assert.AreEqual(entity.FilePath, hydraulicBoundaryDatabase.FilePath);
            Assert.AreEqual(entity.Version, hydraulicBoundaryDatabase.Version);

            HydraulicLocationConfigurationSettings settings = hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings;

            Assert.AreEqual(entity.HydraulicLocationConfigurationSettingsFilePath, settings.FilePath);
            Assert.AreEqual(entity.HydraulicLocationConfigurationSettingsScenarioName, settings.ScenarioName);
            Assert.AreEqual(entity.HydraulicLocationConfigurationSettingsYear, settings.Year);
            Assert.AreEqual(entity.HydraulicLocationConfigurationSettingsScope, settings.Scope);
            Assert.AreEqual(usePreprocessorClosure, settings.UsePreprocessorClosure);
            Assert.AreEqual(entity.HydraulicLocationConfigurationSettingsSeaLevel, settings.SeaLevel);
            Assert.AreEqual(entity.HydraulicLocationConfigurationSettingsRiverDischarge, settings.RiverDischarge);
            Assert.AreEqual(entity.HydraulicLocationConfigurationSettingsLakeLevel, settings.LakeLevel);
            Assert.AreEqual(entity.HydraulicLocationConfigurationSettingsWindDirection, settings.WindDirection);
            Assert.AreEqual(entity.HydraulicLocationConfigurationSettingsWindSpeed, settings.WindSpeed);
            Assert.AreEqual(entity.HydraulicLocationConfigurationSettingsComment, settings.Comment);
        }
        public void GivenSettingsWithPreprocessorSettings_WhenSettingCanUsePreprocessorFalse_ThenPreprocessorSettingsReset()
        {
            // Given
            var settings = new HydraulicLocationConfigurationSettings
            {
                CanUsePreprocessor    = true,
                UsePreprocessor       = true,
                PreprocessorDirectory = "PreprocessorDirectory"
            };

            // When
            settings.CanUsePreprocessor = false;

            // Then
            Assert.IsFalse(settings.CanUsePreprocessor);
            Assert.IsFalse(settings.UsePreprocessor);
            Assert.IsNull(settings.PreprocessorDirectory);
        }
        private static void SetHydraulicLocationConfigurationValues(HydraulicLocationConfigurationSettings settings,
                                                                    string hlcdFilePath = "filePath")
        {
            const string scenarioName           = "ScenarioName";
            const int    year                   = 2017;
            const string scope                  = "Scope";
            const bool   usePreprocessorClosure = false;
            const string seaLevel               = "SeaLevel";
            const string riverDischarge         = "RiverDischarge";
            const string lakeLevel              = "LakeLevel";
            const string windDirection          = "WindDirection";
            const string windSpeed              = "WindSpeed";
            const string comment                = "Comment";

            settings.SetValues(hlcdFilePath, scenarioName, year, scope,
                               usePreprocessorClosure, seaLevel, riverDischarge,
                               lakeLevel, windDirection, windSpeed, comment);
        }
Example #19
0
        public void Create_ValidHydraulicBoundaryDatabase_ReturnsHydraulicBoundaryDatabaseEntity()
        {
            // Setup
            var random = new Random(21);
            var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
            {
                FilePath = "hydraulicBoundaryDatabasefilePath",
                Version  = "Version"
            };

            hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings.SetValues("hlcdFilePath",
                                                                                       "ScenarioName",
                                                                                       random.Next(),
                                                                                       "Scope",
                                                                                       random.NextBoolean(),
                                                                                       "SeaLevel",
                                                                                       "RiverDischarge",
                                                                                       "LakeLevel",
                                                                                       "WindDirection",
                                                                                       "WindSpeed",
                                                                                       "Comment");

            // Call
            HydraulicBoundaryDatabaseEntity entity = hydraulicBoundaryDatabase.Create();

            // Assert
            TestHelper.AssertAreEqualButNotSame(hydraulicBoundaryDatabase.FilePath, entity.FilePath);
            TestHelper.AssertAreEqualButNotSame(hydraulicBoundaryDatabase.Version, entity.Version);

            HydraulicLocationConfigurationSettings settings = hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings;

            TestHelper.AssertAreEqualButNotSame(settings.FilePath, entity.HydraulicLocationConfigurationSettingsFilePath);
            Assert.AreEqual(Convert.ToByte(settings.UsePreprocessorClosure), entity.HydraulicLocationConfigurationSettingsUsePreprocessorClosure);
            TestHelper.AssertAreEqualButNotSame(settings.ScenarioName, entity.HydraulicLocationConfigurationSettingsScenarioName);
            TestHelper.AssertAreEqualButNotSame(settings.Year, entity.HydraulicLocationConfigurationSettingsYear);
            TestHelper.AssertAreEqualButNotSame(settings.Scope, entity.HydraulicLocationConfigurationSettingsScope);
            TestHelper.AssertAreEqualButNotSame(settings.SeaLevel, entity.HydraulicLocationConfigurationSettingsSeaLevel);
            TestHelper.AssertAreEqualButNotSame(settings.RiverDischarge, entity.HydraulicLocationConfigurationSettingsRiverDischarge);
            TestHelper.AssertAreEqualButNotSame(settings.LakeLevel, entity.HydraulicLocationConfigurationSettingsLakeLevel);
            TestHelper.AssertAreEqualButNotSame(settings.WindDirection, entity.HydraulicLocationConfigurationSettingsWindDirection);
            TestHelper.AssertAreEqualButNotSame(settings.WindSpeed, entity.HydraulicLocationConfigurationSettingsWindSpeed);
            TestHelper.AssertAreEqualButNotSame(settings.Comment, entity.HydraulicLocationConfigurationSettingsComment);
        }
Example #20
0
        public void ImportHydraulicLocationConfigurationSettings(HydraulicLocationConfigurationSettings hydraulicLocationConfigurationSettings, string hlcdFilePath)
        {
            if (hydraulicLocationConfigurationSettings == null)
            {
                throw new ArgumentNullException(nameof(hydraulicLocationConfigurationSettings));
            }

            if (hlcdFilePath == null)
            {
                throw new ArgumentNullException(nameof(hlcdFilePath));
            }

            var importSettingsActivity = new FileImportActivity(
                new HydraulicLocationConfigurationDatabaseImporter(hydraulicLocationConfigurationSettings,
                                                                   updateHandler,
                                                                   hydraulicBoundaryDatabase,
                                                                   hlcdFilePath),
                Resources.HydraulicLocationConfigurationDatabaseImportHandler_ImportHydraulicLocationConfigurationSettings_Description);

            ActivityProgressDialogRunner.Run(viewParent, importSettingsActivity);
        }
        public void Constructor_ExpectedValues()
        {
            // Call
            var settings = new HydraulicLocationConfigurationSettings();

            // Assert
            Assert.IsNull(settings.FilePath);
            Assert.IsNull(settings.ScenarioName);
            Assert.AreEqual(0, settings.Year);
            Assert.IsNull(settings.Scope);
            Assert.IsNull(settings.SeaLevel);
            Assert.IsNull(settings.RiverDischarge);
            Assert.IsNull(settings.LakeLevel);
            Assert.IsNull(settings.WindDirection);
            Assert.IsNull(settings.WindSpeed);
            Assert.IsNull(settings.Comment);
            Assert.IsFalse(settings.UsePreprocessorClosure);
            Assert.IsFalse(settings.CanUsePreprocessor);
            Assert.IsFalse(settings.UsePreprocessor);
            Assert.IsNull(settings.PreprocessorDirectory);
        }
Example #22
0
        /// <summary>
        /// Performs all <paramref name="calculations"/>.
        /// </summary>
        /// <param name="calculations">The collection of <see cref="DuneLocationCalculation"/> to perform.</param>
        /// <param name="assessmentSection">The assessment section the calculations belong to.</param>
        /// <param name="targetProbability">The target probability to use during the calculations.</param>
        /// <param name="calculationIdentifier">The calculation identifier to use in all messages.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="calculations"/> or
        /// <paramref name="assessmentSection"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="calculationIdentifier"/> is <c>null</c> or empty.</exception>
        public void Calculate(IEnumerable <DuneLocationCalculation> calculations,
                              IAssessmentSection assessmentSection,
                              double targetProbability,
                              string calculationIdentifier)
        {
            if (calculations == null)
            {
                throw new ArgumentNullException(nameof(calculations));
            }

            if (assessmentSection == null)
            {
                throw new ArgumentNullException(nameof(assessmentSection));
            }

            string hydraulicBoundaryDatabaseFilePath = assessmentSection.HydraulicBoundaryDatabase.FilePath;
            string preprocessorDirectory             = assessmentSection.HydraulicBoundaryDatabase.EffectivePreprocessorDirectory();
            HydraulicLocationConfigurationSettings hydraulicLocationConfigurationSettings = assessmentSection.HydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings;

            string validationProblem = HydraulicBoundaryDatabaseHelper.ValidateFilesForCalculation(hydraulicBoundaryDatabaseFilePath,
                                                                                                   hydraulicLocationConfigurationSettings.FilePath,
                                                                                                   preprocessorDirectory,
                                                                                                   hydraulicLocationConfigurationSettings.UsePreprocessorClosure);

            if (!string.IsNullOrEmpty(validationProblem))
            {
                log.ErrorFormat(RiskeerCommonFormsResources.CalculateHydraulicBoundaryLocation_Start_calculation_failed_0_,
                                validationProblem);
                return;
            }

            ActivityProgressDialogRunner.Run(viewParent,
                                             DuneLocationCalculationActivityFactory.CreateCalculationActivities(calculations,
                                                                                                                assessmentSection,
                                                                                                                targetProbability,
                                                                                                                calculationIdentifier));
        }
        public void SetValues_WithArguments_SetsExpectedValues()
        {
            // Setup
            var          random                 = new Random(21);
            const string filePath               = "FilePath";
            const string scenarioName           = "ScenarioName";
            int          year                   = random.Next();
            const string scope                  = "Scope";
            bool         usePreprocessorClosure = random.NextBoolean();
            const string seaLevel               = "SeaLevel";
            const string riverDischarge         = "RiverDischarge";
            const string lakeLevel              = "LakeLevel";
            const string windDirection          = "WindDirection";
            const string windSpeed              = "WindSpeed";
            const string comment                = "Comment";

            var settings = new HydraulicLocationConfigurationSettings();

            // Call
            settings.SetValues(filePath, scenarioName, year, scope,
                               usePreprocessorClosure, seaLevel, riverDischarge,
                               lakeLevel, windDirection, windSpeed, comment);

            // Assert
            Assert.AreEqual(filePath, settings.FilePath);
            Assert.AreEqual(scenarioName, settings.ScenarioName);
            Assert.AreEqual(year, settings.Year);
            Assert.AreEqual(scope, settings.Scope);
            Assert.AreEqual(usePreprocessorClosure, settings.UsePreprocessorClosure);
            Assert.AreEqual(seaLevel, settings.SeaLevel);
            Assert.AreEqual(riverDischarge, settings.RiverDischarge);
            Assert.AreEqual(lakeLevel, settings.LakeLevel);
            Assert.AreEqual(windDirection, settings.WindDirection);
            Assert.AreEqual(windSpeed, settings.WindSpeed);
            Assert.AreEqual(comment, settings.Comment);
        }
 private static bool AreHydraulicBoundaryLocationConfigurationSettingsEquivalent(HydraulicLocationConfigurationSettings hydraulicLocationConfigurationSettings,
                                                                                 HydraulicLocationConfigurationSettings otherHydraulicLocationConfigurationSettings)
 {
     return(hydraulicLocationConfigurationSettings.ScenarioName == otherHydraulicLocationConfigurationSettings.ScenarioName &&
            hydraulicLocationConfigurationSettings.Year == otherHydraulicLocationConfigurationSettings.Year &&
            hydraulicLocationConfigurationSettings.Scope == otherHydraulicLocationConfigurationSettings.Scope &&
            hydraulicLocationConfigurationSettings.UsePreprocessorClosure == otherHydraulicLocationConfigurationSettings.UsePreprocessorClosure &&
            hydraulicLocationConfigurationSettings.SeaLevel == otherHydraulicLocationConfigurationSettings.SeaLevel &&
            hydraulicLocationConfigurationSettings.RiverDischarge == otherHydraulicLocationConfigurationSettings.RiverDischarge &&
            hydraulicLocationConfigurationSettings.LakeLevel == otherHydraulicLocationConfigurationSettings.LakeLevel &&
            hydraulicLocationConfigurationSettings.WindDirection == otherHydraulicLocationConfigurationSettings.WindDirection &&
            hydraulicLocationConfigurationSettings.WindSpeed == otherHydraulicLocationConfigurationSettings.WindSpeed &&
            hydraulicLocationConfigurationSettings.Comment == otherHydraulicLocationConfigurationSettings.Comment);
 }
Example #25
0
        public void Create_HydraulicBoundaryDatabaseLinked_SetsExpectedPropertiesToEntity()
        {
            // Setup
            var          random       = new Random(21);
            const string testFilePath = "path";
            const string testVersion  = "1";

            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
            {
                HydraulicBoundaryDatabase =
                {
                    FilePath  = testFilePath,
                    Version   = testVersion,
                    Locations =
                    {
                        new HydraulicBoundaryLocation(-1, "name", 1, 2)
                    }
                },
                WaveHeightCalculationsForUserDefinedTargetProbabilities =
                {
                    new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1)),
                    new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1)),
                    new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1))
                },
                WaterLevelCalculationsForUserDefinedTargetProbabilities =
                {
                    new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1)),
                    new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1))
                }
            };

            assessmentSection.SetHydraulicBoundaryLocationCalculations(assessmentSection.HydraulicBoundaryDatabase.Locations);
            SetHydraulicBoundaryLocationCalculationInputsOfAssessmentSection(assessmentSection);

            var registry = new PersistenceRegistry();

            // Call
            AssessmentSectionEntity entity = assessmentSection.Create(registry);

            // Assert
            HydraulicBoundaryDatabaseEntity hydraulicBoundaryDatabaseEntity = entity.HydraulicBoundaryDatabaseEntities.Single();

            HydraulicBoundaryDatabase hydraulicBoundaryDatabase = assessmentSection.HydraulicBoundaryDatabase;

            Assert.AreEqual(hydraulicBoundaryDatabase.FilePath, hydraulicBoundaryDatabaseEntity.FilePath);
            Assert.AreEqual(hydraulicBoundaryDatabase.Version, hydraulicBoundaryDatabaseEntity.Version);

            HydraulicLocationConfigurationSettings settings = hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings;

            Assert.AreEqual(settings.FilePath, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsFilePath);
            Assert.AreEqual(settings.ScenarioName, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsScenarioName);
            Assert.AreEqual(settings.Year, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsYear);
            Assert.AreEqual(settings.Scope, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsScope);
            Assert.AreEqual(settings.SeaLevel, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsSeaLevel);
            Assert.AreEqual(settings.RiverDischarge, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsRiverDischarge);
            Assert.AreEqual(settings.LakeLevel, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsLakeLevel);
            Assert.AreEqual(settings.WindDirection, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsWindDirection);
            Assert.AreEqual(settings.WindSpeed, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsWindSpeed);
            Assert.AreEqual(settings.Comment, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsComment);

            int expectedNrOfHydraulicBoundaryLocations = hydraulicBoundaryDatabase.Locations.Count;

            Assert.AreEqual(expectedNrOfHydraulicBoundaryLocations, entity.HydraulicLocationEntities.Count);

            AssertHydraulicLocationCalculationCollectionEntities(assessmentSection, entity);
        }