Index: Ringtoets/Common/test/Ringtoets.Common.Utils.Test/AssignUnassignCalculationsTest.cs =================================================================== diff -u -r968cbe97d1a910b9bbb0fb52b22ece65126ed675 -r2a0fbe6ec22928831305671ecd4f41030b827250 --- Ringtoets/Common/test/Ringtoets.Common.Utils.Test/AssignUnassignCalculationsTest.cs (.../AssignUnassignCalculationsTest.cs) (revision 968cbe97d1a910b9bbb0fb52b22ece65126ed675) +++ Ringtoets/Common/test/Ringtoets.Common.Utils.Test/AssignUnassignCalculationsTest.cs (.../AssignUnassignCalculationsTest.cs) (revision 2a0fbe6ec22928831305671ecd4f41030b827250) @@ -60,160 +60,15 @@ }; [Test] - public void Update_NullSectionResultsElement_ThrowsArgumentException() - { - // Setup - var mockRepository = new MockRepository(); - var calculation = mockRepository.Stub(); - mockRepository.ReplayAll(); - - var calculationWithLocation = new CalculationWithLocation(calculation, new Point2D(0, 0)); - - // Call - TestDelegate call = () => AssignUnassignCalculations.Update( - new SectionResultWithCalculationAssignment[] - { - null - }, - calculationWithLocation); - - // Assert - ArgumentException exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "SectionResults contains an entry without value."); - Assert.AreEqual("sectionResults", exception.ParamName); - mockRepository.VerifyAll(); - } - - [Test] - public void Update_NullCalculation_ThrowsArgumentNullException() - { - // Setup - var sectionResults = Enumerable.Empty(); - - // Call - TestDelegate call = () => AssignUnassignCalculations.Update(sectionResults, null); - - // Assert - string paramName = Assert.Throws(call).ParamName; - Assert.AreEqual("calculation", paramName); - } - - [Test] public void Update_NullSectionResults_ThrowsArgumentNullException() { // Setup var mockRepository = new MockRepository(); - var calculation = mockRepository.Stub(); mockRepository.ReplayAll(); - var calculationWithLocation = new CalculationWithLocation(calculation, new Point2D(0, 0)); - // Call - TestDelegate call = () => AssignUnassignCalculations.Update(null, calculationWithLocation); - - // Assert - string paramName = Assert.Throws(call).ParamName; - Assert.AreEqual("sectionResults", paramName); - mockRepository.VerifyAll(); - } - - [Test] - public void Update_CalculationLocationChangedToMatchOtherSectionAndOtherSectionWithoutCalculation_FirstSectionResultCalculationNullSecondSectionResultCalculationSet() - { - // Setup - var mockRepository = new MockRepository(); - var calculation = mockRepository.Stub(); - mockRepository.ReplayAll(); - - var calculationLocation = new Point2D(1.51, 1.51); - - var sectionA = new FailureMechanismSection("firstSection", new List - { - new Point2D(0.0, 0.0), new Point2D(1.1, 1.1) - }); - var sectionB = new FailureMechanismSection("secondSection", new List - { - new Point2D(1.1, 1.1), new Point2D(2.2, 2.2) - }); - - var sectionResultA = new FailureMechanismSectionResultWithCalculation(sectionA); - var sectionResultB = new FailureMechanismSectionResultWithCalculation(sectionB); - - var sectionResults = new List - { - new SectionResultWithCalculationAssignment(sectionResultA, - r => ((FailureMechanismSectionResultWithCalculation) r).Calculation, - (r, c) => ((FailureMechanismSectionResultWithCalculation) r).Calculation = c), - new SectionResultWithCalculationAssignment(sectionResultB, - r => ((FailureMechanismSectionResultWithCalculation) r).Calculation, - (r, c) => ((FailureMechanismSectionResultWithCalculation) r).Calculation = c) - }; - sectionResultA.Calculation = calculation; - - // Call - AssignUnassignCalculations.Update(sectionResults, new CalculationWithLocation(calculation, calculationLocation)); - - // Assert - Assert.IsNull(sectionResultA.Calculation); - Assert.AreSame(calculation, sectionResultB.Calculation); - mockRepository.VerifyAll(); - } - - [Test] - public void Update_CalculationLocationChangedToMatchOtherSectionAndOtherSectionHasCalculation_FirstSectionResultCalculationNullSecondSectionResultCalculationUnchanged() - { - // Setup - var mockRepository = new MockRepository(); - var calculationA = mockRepository.Stub(); - var calculationB = mockRepository.Stub(); - mockRepository.ReplayAll(); - - var locationB = new Point2D(1.51, 1.51); - - var sectionA = new FailureMechanismSection("firstSection", new List - { - new Point2D(0.0, 0.0), new Point2D(1.1, 1.1) - }); - var sectionB = new FailureMechanismSection("secondSection", new List - { - new Point2D(1.1, 1.1), new Point2D(2.2, 2.2) - }); - - var sectionResultA = new FailureMechanismSectionResultWithCalculation(sectionA); - var sectionResultB = new FailureMechanismSectionResultWithCalculation(sectionB); - - var sectionResults = new List - { - new SectionResultWithCalculationAssignment(sectionResultA, - r => ((FailureMechanismSectionResultWithCalculation) r).Calculation, - (r, c) => ((FailureMechanismSectionResultWithCalculation) r).Calculation = c), - new SectionResultWithCalculationAssignment(sectionResultB, - r => ((FailureMechanismSectionResultWithCalculation) r).Calculation, - (r, c) => ((FailureMechanismSectionResultWithCalculation) r).Calculation = c) - }; - sectionResultA.Calculation = calculationA; - sectionResultB.Calculation = calculationB; - - // Call - AssignUnassignCalculations.Update(sectionResults, new CalculationWithLocation(calculationA, locationB)); - - // Assert - Assert.IsNull(sectionResultA.Calculation); - Assert.AreSame(calculationB, sectionResultB.Calculation); - mockRepository.VerifyAll(); - } - - [Test] - public void Delete_NullSectionResults_ThrowsArgumentNullException() - { - // Setup - var mockRepository = new MockRepository(); - var calculation = mockRepository.Stub(); - mockRepository.ReplayAll(); - - // Call - TestDelegate call = () => AssignUnassignCalculations.Delete( + TestDelegate call = () => AssignUnassignCalculations.Update( null, - calculation, Enumerable.Empty()); // Assert @@ -224,20 +79,18 @@ } [Test] - public void Delete_NullSectionResultsElement_ThrowsArgumentException() + public void Update_NullSectionResultsElement_ThrowsArgumentException() { // Setup var mockRepository = new MockRepository(); - var calculation = mockRepository.Stub(); mockRepository.ReplayAll(); // Call - TestDelegate call = () => AssignUnassignCalculations.Delete( + TestDelegate call = () => AssignUnassignCalculations.Update( new SectionResultWithCalculationAssignment[] { null }, - calculation, Enumerable.Empty()); // Assert @@ -248,31 +101,15 @@ } [Test] - public void Delete_NullCalculation_ThrowsArgumentNullException() + public void Update_NullCalculations_ThrowsArgumentNullException() { - // Call - TestDelegate call = () => AssignUnassignCalculations.Delete( - Enumerable.Empty(), - null, - Enumerable.Empty()); - - // Assert - string paramName = Assert.Throws(call).ParamName; - Assert.AreEqual("calculation", paramName); - } - - [Test] - public void Delete_NullCalculations_ThrowsArgumentNullException() - { // Setup var mockRepository = new MockRepository(); - var calculation = mockRepository.Stub(); mockRepository.ReplayAll(); // Call - TestDelegate call = () => AssignUnassignCalculations.Delete( + TestDelegate call = () => AssignUnassignCalculations.Update( Enumerable.Empty(), - calculation, null); // Assert @@ -283,17 +120,15 @@ } [Test] - public void Delete_NullCalculationsElement_ThrowsArgumentException() + public void Update_NullCalculationsElement_ThrowsArgumentException() { // Setup var mockRepository = new MockRepository(); - var calculation = mockRepository.Stub(); mockRepository.ReplayAll(); // Call - TestDelegate call = () => AssignUnassignCalculations.Delete( + TestDelegate call = () => AssignUnassignCalculations.Update( Enumerable.Empty(), - calculation, new CalculationWithLocation[] { null @@ -307,7 +142,7 @@ } [Test] - public void Delete_RemoveCalculationAssignedToSectionResult_SectionResultCalculationNull() + public void Update_RemoveCalculationAssignedToSectionResult_SectionResultCalculationNull() { // Setup var mockRepository = new MockRepository(); @@ -330,14 +165,14 @@ sectionResult.Calculation = calculation; // Call - AssignUnassignCalculations.Delete(sectionResults, calculation, Enumerable.Empty()); + AssignUnassignCalculations.Update(sectionResults, Enumerable.Empty()); // Assert Assert.IsNull(sectionResult.Calculation); } [Test] - public void Delete_RemoveCalculationAssignedToSectionResult_SingleRemainingCalculationAssignedToSectionResult() + public void Update_RemoveCalculationAssignedToSectionResult_SingleRemainingCalculationAssignedToSectionResult() { // Setup var mockRepository = new MockRepository(); @@ -363,7 +198,7 @@ sectionResult.Calculation = calculationA; // Call - AssignUnassignCalculations.Delete(sectionResults, calculationA, new[] + AssignUnassignCalculations.Update(sectionResults, new[] { new CalculationWithLocation(calculationB, location), });