private static string[] ValidateInput(HydraulicBoundaryDatabase hydraulicBoundaryDatabase, WaveConditionsInput input, RoundedDouble assessmentLevel) { var validationResults = new List <string>(); string databaseFilePathValidationProblem = HydraulicBoundaryDatabaseConnectionValidator.Validate(hydraulicBoundaryDatabase); if (!string.IsNullOrEmpty(databaseFilePathValidationProblem)) { validationResults.Add(databaseFilePathValidationProblem); } string preprocessorDirectoryValidationProblem = HydraulicBoundaryDatabaseHelper.ValidatePreprocessorDirectory(hydraulicBoundaryDatabase.EffectivePreprocessorDirectory()); if (!string.IsNullOrEmpty(preprocessorDirectoryValidationProblem)) { validationResults.Add(preprocessorDirectoryValidationProblem); } if (validationResults.Any()) { return(validationResults.ToArray()); } validationResults.AddRange(ValidateWaveConditionsInput(input, assessmentLevel)); return(validationResults.ToArray()); }
public void Validate_HydraulicBoundaryDatabaseNull_ThrowsArgumentNullException() { // Call TestDelegate test = () => HydraulicBoundaryDatabaseConnectionValidator.Validate(null); // Assert string paramName = Assert.Throws <ArgumentNullException>(test).ParamName; Assert.AreEqual("hydraulicBoundaryDatabase", paramName); }
public void Validate_HydraulicBoundaryDatabaseNotLinked_ReturnErrorMessage() { // Setup var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); // Call string message = HydraulicBoundaryDatabaseConnectionValidator.Validate(hydraulicBoundaryDatabase); // Assert const string expectedMessage = "Er is geen hydraulische belastingendatabase geïmporteerd."; Assert.AreEqual(expectedMessage, message); }
public void Validate_HydraulicBoundaryDatabaseLinkedToNotExistingDatabaseFile_ReturnsErrorMessage() { // Setup var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { FilePath = "I_do_not_exist.db" }; // Call string message = HydraulicBoundaryDatabaseConnectionValidator.Validate(hydraulicBoundaryDatabase); // Assert const string expectedMessage = "Herstellen van de verbinding met de hydraulische belastingendatabase is mislukt. Fout bij het lezen van bestand 'I_do_not_exist.db': het bestand bestaat niet."; Assert.AreEqual(expectedMessage, message); }
private static IEnumerable <string> ValidateHydraulicBoundaryDatabase(IAssessmentSection assessmentSection) { string preprocessorDirectory = assessmentSection.HydraulicBoundaryDatabase.EffectivePreprocessorDirectory(); string databaseValidationProblem = HydraulicBoundaryDatabaseConnectionValidator.Validate(assessmentSection.HydraulicBoundaryDatabase); if (!string.IsNullOrEmpty(databaseValidationProblem)) { yield return(databaseValidationProblem); } string preprocessorDirectoryValidationProblem = HydraulicBoundaryDatabaseHelper.ValidatePreprocessorDirectory(preprocessorDirectory); if (!string.IsNullOrEmpty(preprocessorDirectoryValidationProblem)) { yield return(preprocessorDirectoryValidationProblem); } }
public void Validate_HydraulicBoundaryDatabaseLinkedToValidDatabaseFile_ReturnsNull(bool usePreprocessorClosure) { // Setup string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { FilePath = validFilePath }; HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase, usePreprocessorClosure); // Call string message = HydraulicBoundaryDatabaseConnectionValidator.Validate(hydraulicBoundaryDatabase); // Assert Assert.IsNull(message); }
/// <summary> /// Validates the input. /// </summary> /// <param name="input">The input of the calculation.</param> /// <param name="assessmentSection">The assessment section that holds /// information about the hydraulic boundary database.</param> /// <returns>An <see cref="Array"/> of validation messages.</returns> /// <exception cref="InvalidEnumArgumentException">Thrown when an unexpected /// enum value is encountered.</exception> private static string[] ValidateInput(TStructureInput input, IAssessmentSection assessmentSection) { var validationResults = new List <string>(); string preprocessorDirectory = assessmentSection.HydraulicBoundaryDatabase.EffectivePreprocessorDirectory(); string databaseFilePathValidationProblem = HydraulicBoundaryDatabaseConnectionValidator.Validate(assessmentSection.HydraulicBoundaryDatabase); if (!string.IsNullOrEmpty(databaseFilePathValidationProblem)) { validationResults.Add(databaseFilePathValidationProblem); } string preprocessorDirectoryValidationProblem = HydraulicBoundaryDatabaseHelper.ValidatePreprocessorDirectory(preprocessorDirectory); if (!string.IsNullOrEmpty(preprocessorDirectoryValidationProblem)) { validationResults.Add(preprocessorDirectoryValidationProblem); } if (validationResults.Any()) { return(validationResults.ToArray()); } if (input.HydraulicBoundaryLocation == null) { validationResults.Add(Resources.CalculationService_ValidateInput_No_hydraulic_boundary_location_selected); } if (input.Structure == null) { validationResults.Add(Resources.StructuresCalculationService_ValidateInput_No_Structure_selected); } else { IEnumerable <ValidationRule> validationRules = new TStructureValidationRules().GetValidationRules(input); foreach (ValidationRule validationRule in validationRules) { validationResults.AddRange(validationRule.Validate()); } } return(validationResults.ToArray()); }
public void Validate_HydraulicBoundaryDatabaseLinkedToExistingDatabaseFileWithoutSettings_ReturnsErrorMessage() { // Setup string invalidFilePath = Path.Combine(testDataPath, "invalidSettingsSchema", "complete.sqlite"); var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { FilePath = invalidFilePath }; HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase); // Call string message = HydraulicBoundaryDatabaseConnectionValidator.Validate(hydraulicBoundaryDatabase); // Assert const string expectedMessage = "Herstellen van de verbinding met de hydraulische belastingendatabase is mislukt. De rekeninstellingen database heeft niet het juiste schema."; Assert.AreEqual(expectedMessage, message); }
public void Validate_UsePreprocessorClosureTrueWithoutPreprocessorClosureFile_ReturnsMessageWithError() { // Setup string validFilePath = Path.Combine(testDataPath, "withoutPreprocessorClosure", "complete.sqlite"); var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { FilePath = validFilePath }; HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase, true); // Call string message = HydraulicBoundaryDatabaseConnectionValidator.Validate(hydraulicBoundaryDatabase); // Assert string preprocessorClosureFilePath = Path.Combine(testDataPath, "withoutPreprocessorClosure", "hlcd_preprocClosure.sqlite"); string expectedMessage = $"Herstellen van de verbinding met de hydraulische belastingendatabase is mislukt. Fout bij het lezen van bestand '{preprocessorClosureFilePath}': het bestand bestaat niet."; Assert.AreEqual(expectedMessage, message); }
private static string EnableValidateAndCalculateMenuItem(IAssessmentSection assessmentSection) { return(HydraulicBoundaryDatabaseConnectionValidator.Validate(assessmentSection.HydraulicBoundaryDatabase)); }