Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs =================================================================== diff -u -r712c1aad8e5486980f259491130e4ae07ea48149 -re5b6ddb7a02c006c9bb38838ac95627b6346571a --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs (.../MacroStabilityOutwardsSectionResultRow.cs) (revision 712c1aad8e5486980f259491130e4ae07ea48149) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs (.../MacroStabilityOutwardsSectionResultRow.cs) (revision e5b6ddb7a02c006c9bb38838ac95627b6346571a) @@ -51,7 +51,8 @@ /// Thrown when any parameter is null. public MacroStabilityOutwardsSectionResultRow(MacroStabilityOutwardsFailureMechanismSectionResult sectionResult, MacroStabilityOutwardsFailureMechanism failureMechanism, - IAssessmentSection assessmentSection) : base(sectionResult) + IAssessmentSection assessmentSection) + : base(sectionResult) { if (failureMechanism == null) { @@ -65,6 +66,8 @@ this.failureMechanism = failureMechanism; this.assessmentSection = assessmentSection; + + Update(); } /// @@ -79,6 +82,7 @@ set { SectionResult.SimpleAssessmentResult = value; + Update(); SectionResult.NotifyObservers(); } } @@ -95,6 +99,7 @@ set { SectionResult.DetailedAssessmentResult = value; + Update(); SectionResult.NotifyObservers(); } } @@ -114,6 +119,7 @@ set { SectionResult.DetailedAssessmentProbability = value; + Update(); SectionResult.NotifyObservers(); } } @@ -130,6 +136,7 @@ set { SectionResult.TailorMadeAssessmentResult = value; + Update(); SectionResult.NotifyObservers(); } } @@ -149,6 +156,7 @@ set { SectionResult.TailorMadeAssessmentProbability = value; + Update(); SectionResult.NotifyObservers(); } } @@ -158,61 +166,28 @@ /// /// Thrown when the /// could not be created. - public FailureMechanismSectionAssemblyCategoryGroup SimpleAssemblyCategoryGroup - { - get - { - return MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); - } - } + public FailureMechanismSectionAssemblyCategoryGroup SimpleAssemblyCategoryGroup { get; private set; } /// /// Gets the detailed assembly category group. /// /// Thrown when the /// could not be created. - public FailureMechanismSectionAssemblyCategoryGroup DetailedAssemblyCategoryGroup - { - get - { - return MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssembly( - SectionResult, - failureMechanism, - assessmentSection); - } - } + public FailureMechanismSectionAssemblyCategoryGroup DetailedAssemblyCategoryGroup { get; private set; } /// /// Gets the tailor made assembly category group. /// /// Thrown when the /// could not be created. - public FailureMechanismSectionAssemblyCategoryGroup TailorMadeAssemblyCategoryGroup - { - get - { - return MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssembly( - SectionResult, - failureMechanism, - assessmentSection); - } - } + public FailureMechanismSectionAssemblyCategoryGroup TailorMadeAssemblyCategoryGroup { get; private set; } /// /// Gets the combined assembly category group. /// /// Thrown when the /// could not be created. - public FailureMechanismSectionAssemblyCategoryGroup CombinedAssemblyCategoryGroup - { - get - { - return MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssembly( - SectionResult, - failureMechanism, - assessmentSection); - } - } + public FailureMechanismSectionAssemblyCategoryGroup CombinedAssemblyCategoryGroup { get; private set; } /// /// Gets or sets the indicator whether the combined assembly should be overwritten by . @@ -226,6 +201,7 @@ set { SectionResult.UseManualAssemblyCategoryGroup = value; + Update(); SectionResult.NotifyObservers(); } } @@ -242,8 +218,34 @@ set { SectionResult.ManualAssemblyCategoryGroup = value; + Update(); SectionResult.NotifyObservers(); } } + + /// + /// Updates the derived assembly category groups. + /// + /// Thrown when the + /// could not be created. + private void Update() + { + SimpleAssemblyCategoryGroup = MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); + + DetailedAssemblyCategoryGroup = MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssembly( + SectionResult, + failureMechanism, + assessmentSection); + + TailorMadeAssemblyCategoryGroup = MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssembly( + SectionResult, + failureMechanism, + assessmentSection); + + CombinedAssemblyCategoryGroup = MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssembly( + SectionResult, + failureMechanism, + assessmentSection); + } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRowTest.cs =================================================================== diff -u -r712c1aad8e5486980f259491130e4ae07ea48149 -re5b6ddb7a02c006c9bb38838ac95627b6346571a --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRowTest.cs (.../MacroStabilityOutwardsSectionResultRowTest.cs) (revision 712c1aad8e5486980f259491130e4ae07ea48149) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRowTest.cs (.../MacroStabilityOutwardsSectionResultRowTest.cs) (revision e5b6ddb7a02c006c9bb38838ac95627b6346571a) @@ -83,40 +83,76 @@ public void Constructor_WithParameters_ExpectedValues() { // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); mocks.ReplayAll(); FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); - // Call - var row = new MacroStabilityOutwardsSectionResultRow(result, new MacroStabilityOutwardsFailureMechanism(), assessmentSection); + using (new AssemblyToolCalculatorFactoryConfig()) + { + // Call + var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); - // Assert - Assert.IsInstanceOf>(row); - Assert.AreEqual(result.SimpleAssessmentResult, row.SimpleAssessmentResult); - Assert.AreEqual(result.DetailedAssessmentResult, row.DetailedAssessmentResult); - Assert.AreEqual(result.DetailedAssessmentProbability, row.DetailedAssessmentProbability); - Assert.AreEqual(result.TailorMadeAssessmentResult, row.TailorMadeAssessmentResult); - Assert.AreEqual(result.TailorMadeAssessmentProbability, row.TailorMadeAssessmentProbability); - Assert.AreEqual(result.UseManualAssemblyCategoryGroup, row.UseManualAssemblyCategoryGroup); - Assert.AreEqual(result.ManualAssemblyCategoryGroup, row.ManualAssemblyCategoryGroup); + // Assert + Assert.IsInstanceOf>(row); + Assert.AreEqual(result.SimpleAssessmentResult, row.SimpleAssessmentResult); + Assert.AreEqual(result.DetailedAssessmentResult, row.DetailedAssessmentResult); + Assert.AreEqual(result.DetailedAssessmentProbability, row.DetailedAssessmentProbability); + Assert.AreEqual(result.TailorMadeAssessmentResult, row.TailorMadeAssessmentResult); + Assert.AreEqual(result.TailorMadeAssessmentProbability, row.TailorMadeAssessmentProbability); + Assert.AreEqual(result.UseManualAssemblyCategoryGroup, row.UseManualAssemblyCategoryGroup); + Assert.AreEqual(result.ManualAssemblyCategoryGroup, row.ManualAssemblyCategoryGroup); - TestHelper.AssertTypeConverter( - nameof(MacroStabilityOutwardsSectionResultRow.DetailedAssessmentProbability)); - TestHelper.AssertTypeConverter( - nameof(MacroStabilityOutwardsSectionResultRow.TailorMadeAssessmentProbability)); + TestHelper.AssertTypeConverter( + nameof(MacroStabilityOutwardsSectionResultRow.DetailedAssessmentProbability)); + TestHelper.AssertTypeConverter( + nameof(MacroStabilityOutwardsSectionResultRow.TailorMadeAssessmentProbability)); + mocks.VerifyAll(); + } } [Test] + public void Constructor_AssemblyThrowsException_ThrowsAssemblyException() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorfactory = (TestAssemblyToolCalculatorFactory)AssemblyToolCalculatorFactory.Instance; + FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + calculator.ThrowExceptionOnCalculate = true; + + // Call + TestDelegate test = () => new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); + + // Assert + Assert.Throws(test); + mocks.VerifyAll(); + } + } + + [Test] public void UseManualAssemblyCategoryGroup_SetNewValue_NotifyObserversAndPropertyChanged() { // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); var observer = mocks.StrictMock(); observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); @@ -125,25 +161,30 @@ var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); result.Attach(observer); - var row = new MacroStabilityOutwardsSectionResultRow(result, new MacroStabilityOutwardsFailureMechanism(), assessmentSection); + using (new AssemblyToolCalculatorFactoryConfig()) + { + var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); - // Precondition - Assert.IsFalse(result.UseManualAssemblyCategoryGroup); + // Precondition + Assert.IsFalse(result.UseManualAssemblyCategoryGroup); - // Call - row.UseManualAssemblyCategoryGroup = true; + // Call + row.UseManualAssemblyCategoryGroup = true; - // Assert - Assert.IsTrue(result.UseManualAssemblyCategoryGroup); - mocks.VerifyAll(); + // Assert + Assert.IsTrue(result.UseManualAssemblyCategoryGroup); + mocks.VerifyAll(); + } } [Test] public void ManualAssemblyCategoryGroup_SetNewValue_NotifyObserversAndPropertyChanged() { // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); var observer = mocks.StrictMock(); observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); @@ -155,14 +196,17 @@ var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); result.Attach(observer); - var row = new MacroStabilityOutwardsSectionResultRow(result, new MacroStabilityOutwardsFailureMechanism(), assessmentSection); + using (new AssemblyToolCalculatorFactoryConfig()) + { + var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); - // Call - row.ManualAssemblyCategoryGroup = newValue; + // Call + row.ManualAssemblyCategoryGroup = newValue; - // Assert - Assert.AreEqual(newValue, result.ManualAssemblyCategoryGroup); - mocks.VerifyAll(); + // Assert + Assert.AreEqual(newValue, result.ManualAssemblyCategoryGroup); + mocks.VerifyAll(); + } } #region Registration @@ -171,35 +215,42 @@ public void SimpleAssessmentResult_SetNewValue_NotifyObserversAndPropertyChanged() { // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); var observer = mocks.StrictMock(); observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); - + var random = new Random(39); var newValue = random.NextEnumValue(); FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); result.Attach(observer); - var row = new MacroStabilityOutwardsSectionResultRow(result, new MacroStabilityOutwardsFailureMechanism(), assessmentSection); + using (new AssemblyToolCalculatorFactoryConfig()) + { + var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); - // Call - row.SimpleAssessmentResult = newValue; + // Call + row.SimpleAssessmentResult = newValue; - // Assert - Assert.AreEqual(newValue, result.SimpleAssessmentResult); - mocks.VerifyAll(); + // Assert + Assert.AreEqual(newValue, result.SimpleAssessmentResult); + mocks.VerifyAll(); + } } [Test] public void DetailedAssessmentResult_SetNewValue_NotifyObserversAndPropertyChanged() { // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); var observer = mocks.StrictMock(); observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); @@ -211,14 +262,17 @@ var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); result.Attach(observer); - var row = new MacroStabilityOutwardsSectionResultRow(result, new MacroStabilityOutwardsFailureMechanism(), assessmentSection); + using (new AssemblyToolCalculatorFactoryConfig()) + { + var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); - // Call - row.DetailedAssessmentResult = newValue; + // Call + row.DetailedAssessmentResult = newValue; - // Assert - Assert.AreEqual(newValue, result.DetailedAssessmentResult); - mocks.VerifyAll(); + // Assert + Assert.AreEqual(newValue, result.DetailedAssessmentResult); + mocks.VerifyAll(); + } } [Test] @@ -230,8 +284,10 @@ public void DetailedAssessmentProbability_ValidValue_NotifyObserversAndPropertyChanged(double value) { // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); var observer = mocks.StrictMock(); observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); @@ -240,14 +296,17 @@ var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); result.Attach(observer); - var row = new MacroStabilityOutwardsSectionResultRow(result, new MacroStabilityOutwardsFailureMechanism(), assessmentSection); + using (new AssemblyToolCalculatorFactoryConfig()) + { + var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); - // Call - row.DetailedAssessmentProbability = value; + // Call + row.DetailedAssessmentProbability = value; - // Assert - Assert.AreEqual(value, row.DetailedAssessmentProbability); - mocks.VerifyAll(); + // Assert + Assert.AreEqual(value, row.DetailedAssessmentProbability); + mocks.VerifyAll(); + } } [Test] @@ -259,30 +318,38 @@ public void DetailedAssessmentProbability_InvalidValue_ThrowsArgumentOutOfRangeException(double value) { // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); mocks.ReplayAll(); FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); - var row = new MacroStabilityOutwardsSectionResultRow(result, new MacroStabilityOutwardsFailureMechanism(), assessmentSection); - // Call - TestDelegate test = () => row.DetailedAssessmentProbability = value; + using (new AssemblyToolCalculatorFactoryConfig()) + { + var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); - // Assert - string message = Assert.Throws(test).Message; - const string expectedMessage = "De waarde voor de faalkans moet in het bereik [0,0, 1,0] liggen."; - Assert.AreEqual(expectedMessage, message); - mocks.VerifyAll(); + // Call + TestDelegate test = () => row.DetailedAssessmentProbability = value; + + // Assert + string message = Assert.Throws(test).Message; + const string expectedMessage = "De waarde voor de faalkans moet in het bereik [0,0, 1,0] liggen."; + Assert.AreEqual(expectedMessage, message); + mocks.VerifyAll(); + } } [Test] public void TailorMadeAssessmentResult_SetNewValue_NotifyObserversAndPropertyChanged() { // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); var observer = mocks.StrictMock(); observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); @@ -294,14 +361,17 @@ var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); result.Attach(observer); - var row = new MacroStabilityOutwardsSectionResultRow(result, new MacroStabilityOutwardsFailureMechanism(), assessmentSection); + using (new AssemblyToolCalculatorFactoryConfig()) + { + var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); - // Call - row.TailorMadeAssessmentResult = newValue; + // Call + row.TailorMadeAssessmentResult = newValue; - // Assert - Assert.AreEqual(newValue, result.TailorMadeAssessmentResult); - mocks.VerifyAll(); + // Assert + Assert.AreEqual(newValue, result.TailorMadeAssessmentResult); + mocks.VerifyAll(); + } } [Test] @@ -313,8 +383,10 @@ public void TailorMadeAssessmentProbability_ValidValue_NotifyObserversAndPropertyChanged(double value) { // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); var observer = mocks.StrictMock(); observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); @@ -323,14 +395,17 @@ var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); result.Attach(observer); - var row = new MacroStabilityOutwardsSectionResultRow(result, new MacroStabilityOutwardsFailureMechanism(), assessmentSection); + using (new AssemblyToolCalculatorFactoryConfig()) + { + var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); - // Call - row.TailorMadeAssessmentProbability = value; + // Call + row.TailorMadeAssessmentProbability = value; - // Assert - Assert.AreEqual(value, row.TailorMadeAssessmentProbability); - mocks.VerifyAll(); + // Assert + Assert.AreEqual(value, row.TailorMadeAssessmentProbability); + mocks.VerifyAll(); + } } [Test] @@ -342,85 +417,36 @@ public void TailorMadeAssessmentProbability_InvalidValue_ThrowsArgumentOutOfRangeException(double value) { // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); - FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); - var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); - var row = new MacroStabilityOutwardsSectionResultRow(result, new MacroStabilityOutwardsFailureMechanism(), assessmentSection); - - // Call - TestDelegate test = () => row.TailorMadeAssessmentProbability = value; - - // Assert - string message = Assert.Throws(test).Message; - const string expectedMessage = "De waarde voor de faalkans moet in het bereik [0,0, 1,0] liggen."; - Assert.AreEqual(expectedMessage, message); - mocks.VerifyAll(); - } - - #endregion - - #region Assembly Results - - [Test] - public void SimpleAssemblyCategoryGroup_AssemblyRan_ReturnCategoryGroup() - { - // Setup var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); mocks.ReplayAll(); FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); - var row = new MacroStabilityOutwardsSectionResultRow(result, new MacroStabilityOutwardsFailureMechanism(), assessmentSection); using (new AssemblyToolCalculatorFactoryConfig()) { - var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; - FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; + var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); // Call - FailureMechanismSectionAssemblyCategoryGroup simpleAssemblyCategoryGroup = row.SimpleAssemblyCategoryGroup; + TestDelegate test = () => row.TailorMadeAssessmentProbability = value; // Assert - FailureMechanismSectionAssembly calculatorOutput = calculator.SimpleAssessmentAssemblyOutput; - Assert.AreEqual(calculatorOutput.Group, simpleAssemblyCategoryGroup); + string message = Assert.Throws(test).Message; + const string expectedMessage = "De waarde voor de faalkans moet in het bereik [0,0, 1,0] liggen."; + Assert.AreEqual(expectedMessage, message); mocks.VerifyAll(); } } - [Test] - public void SimpleAssemblyCategoryGroup_AssemblyThrowsException_ThrowsAssemblyException() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); + #endregion - FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); - var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); - var row = new MacroStabilityOutwardsSectionResultRow(result, new MacroStabilityOutwardsFailureMechanism(), assessmentSection); + #region Assembly Results - using (new AssemblyToolCalculatorFactoryConfig()) - { - var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; - FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; - calculator.ThrowExceptionOnCalculate = true; - - // Call - FailureMechanismSectionAssemblyCategoryGroup simpleAssemblyCategoryGroup; - TestDelegate test = () => simpleAssemblyCategoryGroup = row.SimpleAssemblyCategoryGroup; - - // Assert - Assert.Throws(test); - mocks.VerifyAll(); - } - } - [Test] - public void DetailedAssemblyCategoryGroup_AssemblyRan_ReturnCategoryGroup() + public void SimpleAssemblyCategoryGroup_AssemblyRan_ReturnCategoryGroup() { // Setup var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); @@ -431,25 +457,26 @@ FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); - var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); using (new AssemblyToolCalculatorFactoryConfig()) { + var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; // Call - FailureMechanismSectionAssemblyCategoryGroup detailedAssemblyCategoryGroup = row.DetailedAssemblyCategoryGroup; + FailureMechanismSectionAssemblyCategoryGroup simpleAssemblyCategoryGroup = row.SimpleAssemblyCategoryGroup; // Assert - FailureMechanismSectionAssembly calculatorOutput = calculator.DetailedAssessmentAssemblyOutput; - Assert.AreEqual(calculatorOutput.Group, detailedAssemblyCategoryGroup); + FailureMechanismSectionAssembly calculatorOutput = calculator.SimpleAssessmentAssemblyOutput; + Assert.AreEqual(calculatorOutput.Group, simpleAssemblyCategoryGroup); mocks.VerifyAll(); } } [Test] - public void DetailedAssemblyCategoryGroup_AssemblyThrowsException_ThrowsAssemblyException() + public void DetailedAssemblyCategoryGroup_AssemblyRan_ReturnCategoryGroup() { // Setup var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); @@ -460,20 +487,20 @@ FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); - var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); using (new AssemblyToolCalculatorFactoryConfig()) { + var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; - calculator.ThrowExceptionOnCalculate = true; // Call - FailureMechanismSectionAssemblyCategoryGroup detailedAssemblyCategoryGroup; - TestDelegate test = () => detailedAssemblyCategoryGroup = row.DetailedAssemblyCategoryGroup; + FailureMechanismSectionAssemblyCategoryGroup detailedAssemblyCategoryGroup = row.DetailedAssemblyCategoryGroup; // Assert - Assert.Throws(test); + FailureMechanismSectionAssembly calculatorOutput = calculator.DetailedAssessmentAssemblyOutput; + Assert.AreEqual(calculatorOutput.Group, detailedAssemblyCategoryGroup); mocks.VerifyAll(); } } @@ -490,10 +517,11 @@ FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); - var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); using (new AssemblyToolCalculatorFactoryConfig()) { + var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; @@ -508,36 +536,6 @@ } [Test] - public void TailorMadeAssemblyCategoryGroup_AssemblyThrowsException_ThrowsAssemblyException() - { - // Setup - var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); - - var mocks = new MockRepository(); - IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); - mocks.ReplayAll(); - - FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); - var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); - var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); - - using (new AssemblyToolCalculatorFactoryConfig()) - { - var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; - FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; - calculator.ThrowExceptionOnCalculate = true; - - // Call - FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssemblyCategoryGroup; - TestDelegate test = () => tailorMadeAssemblyCategoryGroup = row.TailorMadeAssemblyCategoryGroup; - - // Assert - Assert.Throws(test); - mocks.VerifyAll(); - } - } - - [Test] public void CombinedAssemblyCategoryGroup_AssemblyRan_ReturnCategoryGroup() { // Setup @@ -549,10 +547,11 @@ FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); - var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); using (new AssemblyToolCalculatorFactoryConfig()) { + var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); + var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; @@ -566,36 +565,6 @@ } } - [Test] - public void CombinedAssemblyCategoryGroup_AssemblyThrowsException_ThrowsAssemblyException() - { - // Setup - var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); - - var mocks = new MockRepository(); - IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); - mocks.ReplayAll(); - - FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); - var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); - var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection); - - using (new AssemblyToolCalculatorFactoryConfig()) - { - var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; - FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; - calculator.ThrowExceptionOnCalculate = true; - - // Call - FailureMechanismSectionAssemblyCategoryGroup combinedAssemblyCategoryGroup; - TestDelegate test = () => combinedAssemblyCategoryGroup = row.CombinedAssemblyCategoryGroup; - - // Assert - Assert.Throws(test); - mocks.VerifyAll(); - } - } - #endregion } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/MacrostabilityOutwardsResultViewTest.cs =================================================================== diff -u -r712c1aad8e5486980f259491130e4ae07ea48149 -re5b6ddb7a02c006c9bb38838ac95627b6346571a --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/MacrostabilityOutwardsResultViewTest.cs (.../MacrostabilityOutwardsResultViewTest.cs) (revision 712c1aad8e5486980f259491130e4ae07ea48149) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/MacrostabilityOutwardsResultViewTest.cs (.../MacrostabilityOutwardsResultViewTest.cs) (revision e5b6ddb7a02c006c9bb38838ac95627b6346571a) @@ -216,8 +216,10 @@ bool cellsEnabled) { // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); mocks.ReplayAll(); var result = new MacroStabilityOutwardsFailureMechanismSectionResult( @@ -234,7 +236,7 @@ // Call using (var form = new Form()) using (new AssemblyToolCalculatorFactoryConfig()) - using (var view = new MacroStabilityOutwardsResultView(sectionResults, new MacroStabilityOutwardsFailureMechanism(), assessmentSection)) + using (var view = new MacroStabilityOutwardsResultView(sectionResults, failureMechanism, assessmentSection)) { form.Controls.Add(view); form.Show(); @@ -262,8 +264,10 @@ bool cellEnabled) { // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); mocks.ReplayAll(); var result = new MacroStabilityOutwardsFailureMechanismSectionResult( @@ -279,7 +283,7 @@ // Call using (var form = new Form()) using (new AssemblyToolCalculatorFactoryConfig()) - using (var view = new MacroStabilityOutwardsResultView(sectionResults, new MacroStabilityOutwardsFailureMechanism(), assessmentSection)) + using (var view = new MacroStabilityOutwardsResultView(sectionResults, failureMechanism, assessmentSection)) { form.Controls.Add(view); form.Show(); @@ -307,8 +311,10 @@ bool cellEnabled) { // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); mocks.ReplayAll(); var result = new MacroStabilityOutwardsFailureMechanismSectionResult( @@ -324,7 +330,7 @@ // Call using (var form = new Form()) using (new AssemblyToolCalculatorFactoryConfig()) - using (var view = new MacroStabilityOutwardsResultView(sectionResults, new MacroStabilityOutwardsFailureMechanism(), assessmentSection)) + using (var view = new MacroStabilityOutwardsResultView(sectionResults, failureMechanism, assessmentSection)) { form.Controls.Add(view); form.Show(); @@ -347,8 +353,10 @@ public void FailureMechanismResultView_UseManualAssemblyCategoryGroupSet_CellDisabledEnabled(bool useManualAssemblyCategoryGroup) { // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); mocks.ReplayAll(); var result = new MacroStabilityOutwardsFailureMechanismSectionResult( @@ -365,7 +373,7 @@ // Call using (var form = new Form()) using (new AssemblyToolCalculatorFactoryConfig()) - using (var view = new MacroStabilityOutwardsResultView(sectionResults, new MacroStabilityOutwardsFailureMechanism(), assessmentSection)) + using (var view = new MacroStabilityOutwardsResultView(sectionResults, failureMechanism, assessmentSection)) { form.Controls.Add(view); form.Show();