Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/HeightStructuresCalculationServiceTest.cs =================================================================== diff -u -r7194f9760969f736d93069f4c833bedd8b1f540b -r4997c48d331087a7f1fa40a7874a6f7d6ab1abd4 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/HeightStructuresCalculationServiceTest.cs (.../HeightStructuresCalculationServiceTest.cs) (revision 7194f9760969f736d93069f4c833bedd8b1f540b) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/HeightStructuresCalculationServiceTest.cs (.../HeightStructuresCalculationServiceTest.cs) (revision 4997c48d331087a7f1fa40a7874a6f7d6ab1abd4) @@ -32,7 +32,6 @@ using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Hydraulics; -using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Service.Structures; using Ringtoets.Common.Service.TestUtil; @@ -60,175 +59,10 @@ var service = new HeightStructuresCalculationService(); // Assert - Assert.IsInstanceOf(service); + Assert.IsInstanceOf>(service); } [Test] - public void Validate_CalculationNull_ThrowArgumentNullException() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); - - // Call - TestDelegate test = () => HeightStructuresCalculationService.Validate(null, assessmentSection); - - // Assert - var exception = Assert.Throws(test); - Assert.AreEqual("calculation", exception.ParamName); - mocks.VerifyAll(); - } - - [Test] - public void Validate_AssessmentSectionNull_ThrowArgumentNullException() - { - // Setup - var calculation = new TestHeightStructuresCalculation(); - - // Call - TestDelegate test = () => HeightStructuresCalculationService.Validate(calculation, null); - - // Assert - var exception = Assert.Throws(test); - Assert.AreEqual("assessmentSection", exception.ParamName); - } - - [Test] - public void Validate_ValidCalculationInvalidHydraulicBoundaryDatabase_ReturnsFalse() - { - // Setup - var mockRepository = new MockRepository(); - IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(new HeightStructuresFailureMechanism(), mockRepository); - mockRepository.ReplayAll(); - - assessmentSectionStub.HydraulicBoundaryDatabase.FilePath = Path.Combine(testDataPath, "notexisting.sqlite"); - - var calculation = new TestHeightStructuresCalculation(); - - // Call - var isValid = true; - Action call = () => isValid = HeightStructuresCalculationService.Validate(calculation, assessmentSectionStub); - - // Assert - TestHelper.AssertLogMessages(call, messages => - { - string[] msgs = messages.ToArray(); - Assert.AreEqual(3, msgs.Length); - CalculationServiceTestHelper.AssertValidationStartMessage(msgs[0]); - StringAssert.StartsWith("Validatie mislukt: Fout bij het lezen van bestand", msgs[1]); - CalculationServiceTestHelper.AssertValidationEndMessage(msgs[2]); - }); - Assert.IsFalse(isValid); - - mockRepository.VerifyAll(); - } - - [Test] - public void Validate_ValidCalculationValidHydraulicBoundaryDatabaseNoSettings_ReturnsFalse() - { - // Setup - var mockRepository = new MockRepository(); - IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(new HeightStructuresFailureMechanism(), mockRepository); - mockRepository.ReplayAll(); - - assessmentSectionStub.HydraulicBoundaryDatabase.FilePath = Path.Combine(testDataPath, "HRD nosettings.sqlite"); - - var calculation = new TestHeightStructuresCalculation(); - - // Call - var isValid = false; - Action call = () => isValid = HeightStructuresCalculationService.Validate(calculation, assessmentSectionStub); - - // Assert - TestHelper.AssertLogMessages(call, messages => - { - string[] msgs = messages.ToArray(); - Assert.AreEqual(3, msgs.Length); - CalculationServiceTestHelper.AssertValidationStartMessage(msgs[0]); - StringAssert.StartsWith("Validatie mislukt: Fout bij het lezen van bestand", msgs[1]); - CalculationServiceTestHelper.AssertValidationEndMessage(msgs[2]); - }); - Assert.IsFalse(isValid); - - mockRepository.VerifyAll(); - } - - [Test] - public void Validate_CalculationInputWithoutStructureValidHydraulicBoundaryDatabase_ReturnsFalse() - { - // Setup - var mockRepository = new MockRepository(); - IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(new HeightStructuresFailureMechanism(), mockRepository); - mockRepository.ReplayAll(); - - assessmentSectionStub.HydraulicBoundaryDatabase.FilePath = validFilePath; - - const string name = ""; - - var calculation = new StructuresCalculation - { - Name = name, - InputParameters = - { - HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "name", 2, 2) - } - }; - - // Call - var isValid = false; - Action call = () => isValid = HeightStructuresCalculationService.Validate(calculation, assessmentSectionStub); - - // Assert - TestHelper.AssertLogMessages(call, messages => - { - string[] msgs = messages.ToArray(); - Assert.AreEqual(3, msgs.Length); - CalculationServiceTestHelper.AssertValidationStartMessage(msgs[0]); - StringAssert.StartsWith("Validatie mislukt: Er is geen kunstwerk geselecteerd.", msgs[1]); - CalculationServiceTestHelper.AssertValidationEndMessage(msgs[2]); - }); - Assert.IsFalse(isValid); - - mockRepository.VerifyAll(); - } - - [Test] - public void Validate_CalculationInputWithoutHydraulicBoundaryLocationValidHydraulicBoundaryDatabase_LogsErrorAndReturnsFalse() - { - // Setup - var mockRepository = new MockRepository(); - IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(new HeightStructuresFailureMechanism(), mockRepository); - mockRepository.ReplayAll(); - - assessmentSectionStub.HydraulicBoundaryDatabase.FilePath = validFilePath; - - const string name = ""; - - var calculation = new TestHeightStructuresCalculation - { - Name = name - }; - - // Call - var isValid = false; - Action call = () => isValid = HeightStructuresCalculationService.Validate(calculation, assessmentSectionStub); - - // Assert - TestHelper.AssertLogMessages(call, messages => - { - string[] msgs = messages.ToArray(); - Assert.AreEqual(3, msgs.Length); - CalculationServiceTestHelper.AssertValidationStartMessage(msgs[0]); - Assert.AreEqual("Validatie mislukt: Er is geen hydraulische randvoorwaardenlocatie geselecteerd.", msgs[1]); - CalculationServiceTestHelper.AssertValidationEndMessage(msgs[2]); - }); - Assert.IsFalse(isValid); - - mockRepository.VerifyAll(); - } - - [Test] public void Validate_StructureNormalOrientationInvalid_ReturnsFalse() { // Setup