Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStubTest.cs =================================================================== diff -u -r5054dd8dca09c2c282b4c7aaccd4214c18413cd1 -r5e1feba6657197e25ffc33e18eec17d2eca6a26d --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStubTest.cs (.../FailureMechanismSectionAssemblyCalculatorStubTest.cs) (revision 5054dd8dca09c2c282b4c7aaccd4214c18413cd1) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStubTest.cs (.../FailureMechanismSectionAssemblyCalculatorStubTest.cs) (revision 5e1feba6657197e25ffc33e18eec17d2eca6a26d) @@ -943,6 +943,81 @@ #region Combined Assembly [Test] + public void AssembleCombinedWithProbabilitiesAndSimpleAssemblyOnly_ThrowExceptionOnCalculateCombinedAssemblyFalseAndOutputNotSet_ReturnOutput() + { + // Setup + var random = new Random(39); + var simpleAssembly = new FailureMechanismSectionAssembly( + random.NextDouble(), + random.NextEnumValue()); + + var calculator = new FailureMechanismSectionAssemblyCalculatorStub(); + + // Call + FailureMechanismSectionAssembly combinedAssembly = calculator.AssembleCombined(simpleAssembly); + + // Assert + Assert.AreSame(simpleAssembly, combinedAssembly); + } + + [Test] + public void AssembleCombinedWithProbabilitiesAndSimpleAssemblyOnly_ThrowExceptionOnCalculateCombinedAssemblyFalseAndOutputSet_ReturnOutput() + { + // Setup + var random = new Random(39); + var calculator = new FailureMechanismSectionAssemblyCalculatorStub + { + CombinedAssemblyOutput = new FailureMechanismSectionAssembly( + random.NextDouble(), + random.NextEnumValue()) + }; + + // Call + FailureMechanismSectionAssembly combinedAssembly = calculator.AssembleCombined(null); + + // Assert + Assert.AreSame(calculator.CombinedAssemblyOutput, combinedAssembly); + } + + [Test] + public void AssembleCombinedWithProbabilitiesAndSimpleAssemblyOnly_ThrowExceptionOnCalculateCombinedAssemblyFalse_SetsInput() + { + // Setup + var random = new Random(39); + var simpleAssembly = new FailureMechanismSectionAssembly( + random.NextDouble(), + random.NextEnumValue()); + + var calculator = new FailureMechanismSectionAssemblyCalculatorStub(); + + // Call + calculator.AssembleCombined(simpleAssembly); + + // Assert + Assert.AreSame(simpleAssembly, calculator.CombinedSimpleAssemblyInput); + Assert.IsNull(calculator.CombinedDetailedAssemblyInput); + Assert.IsNull(calculator.CombinedTailorMadeAssemblyInput); + } + + [Test] + public void AssembleCombinedWithProbabilitiesAndSimpleAssemblyOnly_ThrowExceptionOnCalculateCombinedAssemblyTrue_ThrowsFailureMechanismSectionAssemblyCalculatorException() + { + // Setup + var calculator = new FailureMechanismSectionAssemblyCalculatorStub + { + ThrowExceptionOnCalculateCombinedAssembly = true + }; + + // Call + TestDelegate test = () => calculator.AssembleCombined(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Message", exception.Message); + Assert.IsNotNull(exception.InnerException); + } + + [Test] public void AssembleCombinedWithProbabilities_ThrowExceptionOnCalculateCombinedAssemblyFalseAndOutputNotSet_ReturnOutput() { // Setup @@ -1024,6 +1099,75 @@ } [Test] + public void AssembleCombinedWithSimpleAssemblyOnly_ThrowExceptionOnCalculateCombinedAssemblyFalseAndOutputNotSet_ReturnOutput() + { + // Setup + var random = new Random(39); + var simpleAssembly = random.NextEnumValue(); + + var calculator = new FailureMechanismSectionAssemblyCalculatorStub(); + + // Call + FailureMechanismSectionAssemblyCategoryGroup combinedAssembly = calculator.AssembleCombined(simpleAssembly); + + // Assert + Assert.AreEqual(simpleAssembly, combinedAssembly); + } + + [Test] + public void AssembleCombinedWithSimpleAssemblyOnly_ThrowExceptionOnCalculateCombinedAssemblyFalseAndOutputSet_ReturnOutput() + { + // Setup + var random = new Random(39); + var calculator = new FailureMechanismSectionAssemblyCalculatorStub + { + CombinedAssemblyCategoryOutput = random.NextEnumValue() + }; + + // Call + FailureMechanismSectionAssemblyCategoryGroup combinedAssembly = calculator.AssembleCombined(0); + + // Assert + Assert.AreEqual(calculator.CombinedAssemblyCategoryOutput, combinedAssembly); + } + + [Test] + public void AssembleCombinedWithSimpleAssemblyOnly_ThrowExceptionOnCalculateCombinedAssemblyFalse_SetsInput() + { + // Setup + var random = new Random(39); + var simpleAssembly = random.NextEnumValue(); + + var calculator = new FailureMechanismSectionAssemblyCalculatorStub(); + + // Call + calculator.AssembleCombined(simpleAssembly); + + // Assert + Assert.AreEqual(simpleAssembly, calculator.CombinedSimpleAssemblyGroupInput); + Assert.AreEqual((FailureMechanismSectionAssemblyCategoryGroup) 0, calculator.CombinedDetailedAssemblyGroupInput); + Assert.AreEqual((FailureMechanismSectionAssemblyCategoryGroup) 0, calculator.CombinedTailorMadeAssemblyGroupInput); + } + + [Test] + public void AssembleCombinedWithSimpleAssemblyOnly_ThrowExceptionOnCalculateCombinedAssemblyTrue_ThrowsFailureMechanismSectionAssemblyCalculatorException() + { + // Setup + var calculator = new FailureMechanismSectionAssemblyCalculatorStub + { + ThrowExceptionOnCalculateCombinedAssembly = true + }; + + // Call + TestDelegate test = () => calculator.AssembleCombined(0); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Message", exception.Message); + Assert.IsNotNull(exception.InnerException); + } + + [Test] public void AssembleCombined_ThrowExceptionOnCalculateCombinedAssemblyFalseAndOutputNotSet_ReturnOutput() { // Setup Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStub.cs =================================================================== diff -u -r28bcc5f05ac19148d432c3051a88758c60c9dc0c -r5e1feba6657197e25ffc33e18eec17d2eca6a26d --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStub.cs (.../FailureMechanismSectionAssemblyCalculatorStub.cs) (revision 28bcc5f05ac19148d432c3051a88758c60c9dc0c) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStub.cs (.../FailureMechanismSectionAssemblyCalculatorStub.cs) (revision 5e1feba6657197e25ffc33e18eec17d2eca6a26d) @@ -403,6 +403,18 @@ return TailorMadeAssemblyCategoryOutput.Value; } + public FailureMechanismSectionAssembly AssembleCombined(FailureMechanismSectionAssembly simpleAssembly) + { + if (ThrowExceptionOnCalculateCombinedAssembly) + { + throw new FailureMechanismSectionAssemblyCalculatorException("Message", new Exception()); + } + + CombinedSimpleAssemblyInput = simpleAssembly; + + return CombinedAssemblyOutput ?? (CombinedAssemblyOutput = simpleAssembly); + } + public FailureMechanismSectionAssembly AssembleCombined(FailureMechanismSectionAssembly simpleAssembly, FailureMechanismSectionAssembly detailedAssembly, FailureMechanismSectionAssembly tailorMadeAssembly) @@ -419,6 +431,23 @@ return CombinedAssemblyOutput ?? (CombinedAssemblyOutput = tailorMadeAssembly); } + public FailureMechanismSectionAssemblyCategoryGroup AssembleCombined(FailureMechanismSectionAssemblyCategoryGroup simpleAssembly) + { + if (ThrowExceptionOnCalculateCombinedAssembly) + { + throw new FailureMechanismSectionAssemblyCalculatorException("Message", new Exception()); + } + + CombinedSimpleAssemblyGroupInput = simpleAssembly; + + if (CombinedAssemblyCategoryOutput == null) + { + CombinedAssemblyCategoryOutput = simpleAssembly; + } + + return CombinedAssemblyCategoryOutput.Value; + } + public FailureMechanismSectionAssemblyCategoryGroup AssembleCombined(FailureMechanismSectionAssemblyCategoryGroup simpleAssembly, FailureMechanismSectionAssemblyCategoryGroup detailedAssembly, FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly)