Index: Riskeer/Common/test/Riskeer.Common.Forms.Test/Views/GeneralResultIllustrationPointViewTest.cs =================================================================== diff -u -r3ec593cfb19419112065efb11ea7af54c3b154b6 -r6dfe83bd6ae8835bfab1a07e485f171c25b18668 --- Riskeer/Common/test/Riskeer.Common.Forms.Test/Views/GeneralResultIllustrationPointViewTest.cs (.../GeneralResultIllustrationPointViewTest.cs) (revision 3ec593cfb19419112065efb11ea7af54c3b154b6) +++ Riskeer/Common/test/Riskeer.Common.Forms.Test/Views/GeneralResultIllustrationPointViewTest.cs (.../GeneralResultIllustrationPointViewTest.cs) (revision 6dfe83bd6ae8835bfab1a07e485f171c25b18668) @@ -121,7 +121,7 @@ mocks.VerifyAll(); } - + [Test] public void Constructor_GeneralResultWithoutIllustrationPoints_DataSetOnIllustrationPointControl() { @@ -139,7 +139,7 @@ mocks.VerifyAll(); } - + [Test] public void Constructor_GeneralResultWithIllustrationPoints_DataSetOnIllustrationPointControl() { @@ -149,36 +149,17 @@ mocks.ReplayAll(); GeneralResult generalResult = GetGeneralResultWithTwoTopLevelIllustrationPoints(); - + // Call var view = new TestGeneralResultIllustrationPointView(calculation, () => generalResult); // Assert - TestTopLevelIllustrationPoint topLevelFaultTreeIllustrationPoint1 = generalResult.TopLevelIllustrationPoints.ElementAt(0); - TestTopLevelIllustrationPoint topLevelFaultTreeIllustrationPoint2 = generalResult.TopLevelIllustrationPoints.ElementAt(1); - - var illustrationPoint = new TestIllustrationPoint(); - - var expectedControlItems = new[] - { - new IllustrationPointControlItem(topLevelFaultTreeIllustrationPoint1, - topLevelFaultTreeIllustrationPoint1.WindDirection.Name, - topLevelFaultTreeIllustrationPoint1.ClosingSituation, - stochasts, - illustrationPoint.Beta), - new IllustrationPointControlItem(topLevelFaultTreeIllustrationPoint2, - topLevelFaultTreeIllustrationPoint2.WindDirection.Name, - topLevelFaultTreeIllustrationPoint2.ClosingSituation, - stochasts, - illustrationPoint.Beta) - }; - IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(view); - CollectionAssert.AreEqual(expectedControlItems, illustrationPointsControl.Data, new IllustrationPointControlItemComparer()); + AssertIllustrationPointControlItems(generalResult, illustrationPointsControl); mocks.VerifyAll(); } - + [Test] public void Constructor_GeneralResultFuncReturningEmptyData_SelectionNull() { @@ -292,7 +273,7 @@ var calculation = new TestCalculation(); GeneralResult generalResult = GetGeneralResultWithTwoTopLevelIllustrationPoints(); - + using (var view = new TestGeneralResultIllustrationPointView(calculation, () => returnGeneralResult ? generalResult : null)) @@ -307,26 +288,7 @@ calculation.NotifyObservers(); // Then - TestTopLevelIllustrationPoint topLevelFaultTreeIllustrationPoint1 = generalResult.TopLevelIllustrationPoints.ElementAt(0); - TestTopLevelIllustrationPoint topLevelFaultTreeIllustrationPoint2 = generalResult.TopLevelIllustrationPoints.ElementAt(1); - - var illustrationPoint = new TestIllustrationPoint(); - - var expectedControlItems = new[] - { - new IllustrationPointControlItem(topLevelFaultTreeIllustrationPoint1, - topLevelFaultTreeIllustrationPoint1.WindDirection.Name, - topLevelFaultTreeIllustrationPoint1.ClosingSituation, - stochasts, - illustrationPoint.Beta), - new IllustrationPointControlItem(topLevelFaultTreeIllustrationPoint2, - topLevelFaultTreeIllustrationPoint2.WindDirection.Name, - topLevelFaultTreeIllustrationPoint2.ClosingSituation, - stochasts, - illustrationPoint.Beta) - }; - - CollectionAssert.AreEqual(expectedControlItems, illustrationPointsControl.Data, new IllustrationPointControlItemComparer()); + AssertIllustrationPointControlItems(generalResult, illustrationPointsControl); } } @@ -346,6 +308,19 @@ ShowTestView(view); // Precondition + IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(view); + AssertIllustrationPointControlItems(generalResult, illustrationPointsControl); + + // When + returnGeneralResult = false; + calculation.NotifyObservers(); + + // Then + CollectionAssert.IsEmpty(illustrationPointsControl.Data); + } + + private static void AssertIllustrationPointControlItems(GeneralResult generalResult, IllustrationPointsControl illustrationPointsControl) + { TestTopLevelIllustrationPoint topLevelFaultTreeIllustrationPoint1 = generalResult.TopLevelIllustrationPoints.ElementAt(0); TestTopLevelIllustrationPoint topLevelFaultTreeIllustrationPoint2 = generalResult.TopLevelIllustrationPoints.ElementAt(1); @@ -364,15 +339,8 @@ stochasts, illustrationPoint.Beta) }; - IllustrationPointsControl illustrationPointsControl = GetIllustrationPointsControl(view); - CollectionAssert.AreEqual(expectedControlItems, illustrationPointsControl.Data, new IllustrationPointControlItemComparer()); - // When - returnGeneralResult = false; - calculation.NotifyObservers(); - - // Then - CollectionAssert.IsEmpty(illustrationPointsControl.Data); + CollectionAssert.AreEqual(expectedControlItems, illustrationPointsControl.Data, new IllustrationPointControlItemComparer()); } private static IllustrationPointsControl GetIllustrationPointsControl(TestGeneralResultIllustrationPointView view) @@ -437,6 +405,5 @@ return selection.Source; } } - } } \ No newline at end of file