Пример #1
0
        public void WaveHeightCalculationsView_CalculationUpdated_IllustrationPointsControlCorrectlyUpdated()
        {
            // Setup
            IObservableEnumerable <HydraulicBoundaryLocationCalculation> hydraulicBoundaryLocationCalculations = GetTestHydraulicBoundaryLocationCalculations();

            ShowFullyConfiguredWaveHeightCalculationsView(hydraulicBoundaryLocationCalculations, testForm);

            IllustrationPointsControl illustrationPointsControl       = GetIllustrationPointsControl();
            DataGridViewControl       calculationsDataGridViewControl = GetCalculationsDataGridViewControl();

            calculationsDataGridViewControl.SetCurrentCell(calculationsDataGridViewControl.GetCell(2, 0));

            // Precondition
            CollectionAssert.IsEmpty(illustrationPointsControl.Data);

            var topLevelIllustrationPoints = new[]
            {
                new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(),
                                                          "Regular",
                                                          new TestSubMechanismIllustrationPoint())
            };
            var generalResult = new TestGeneralResultSubMechanismIllustrationPoint(topLevelIllustrationPoints);
            var output        = new TestHydraulicBoundaryLocationCalculationOutput(generalResult);

            // Call
            HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation = hydraulicBoundaryLocationCalculations.ElementAt(2);

            hydraulicBoundaryLocationCalculation.Output = output;
            hydraulicBoundaryLocationCalculation.NotifyObservers();

            // Assert
            IEnumerable <IllustrationPointControlItem> expectedControlItems = CreateControlItems(generalResult);

            CollectionAssert.AreEqual(expectedControlItems, illustrationPointsControl.Data, new IllustrationPointControlItemComparer());
        }
        public void Constructor_InvalidTargetProbability_ThrowsArgumentOutOfRangeException([Values(-0.01, 1.01)] double targetProbability,
                                                                                           [Values(true, false)] bool withIllustrationPoints)
        {
            // Setup
            var random = new Random(32);
            TestGeneralResultSubMechanismIllustrationPoint generalResult = withIllustrationPoints
                                                                               ? new TestGeneralResultSubMechanismIllustrationPoint()
                                                                               : null;

            // Call
            TestDelegate call = () =>
            {
                new HydraulicBoundaryLocationCalculationOutput(random.NextDouble(),
                                                               targetProbability,
                                                               random.NextDouble(),
                                                               random.NextDouble(),
                                                               random.NextDouble(),
                                                               random.NextEnumValue <CalculationConvergence>(),
                                                               generalResult);
            };

            // Assert
            var exception = Assert.Throws <ArgumentOutOfRangeException>(call);

            Assert.AreEqual("targetProbability", exception.ParamName);
            StringAssert.Contains("Kans moet in het bereik [0,0, 1,0] liggen.", exception.Message);
        }
        public void ClearIllustrationPoints_OutputWithGeneralResult_ClearsGeneralResultAndOtherOutputIsNotAffected()
        {
            // Setup
            var    random                = new Random(32);
            double result                = random.NextDouble();
            double targetProbability     = random.NextDouble();
            double targetReliability     = random.NextDouble();
            double calculatedProbability = random.NextDouble();
            double calculatedReliability = random.NextDouble();
            var    convergence           = random.NextEnumValue <CalculationConvergence>();

            var generalResult = new TestGeneralResultSubMechanismIllustrationPoint();

            var output = new HydraulicBoundaryLocationCalculationOutput(result,
                                                                        targetProbability,
                                                                        targetReliability,
                                                                        calculatedProbability,
                                                                        calculatedReliability,
                                                                        convergence,
                                                                        generalResult);

            // Call
            output.ClearIllustrationPoints();

            // Assert
            Assert.AreEqual(result, output.Result, output.Result.GetAccuracy());
            Assert.AreEqual(targetProbability, output.TargetProbability);
            Assert.AreEqual(targetReliability, output.TargetReliability, output.TargetReliability.GetAccuracy());
            Assert.AreEqual(calculatedProbability, output.CalculatedProbability);
            Assert.AreEqual(calculatedReliability, output.CalculatedReliability, output.CalculatedReliability.GetAccuracy());
            Assert.AreEqual(convergence, output.CalculationConvergence);
            Assert.IsNull(output.GeneralResult);
            Assert.IsFalse(output.HasGeneralResult);
        }
        public void Constructor_ValidInputAndGeneralResultNotNull_ExpectedProperties()
        {
            // Setup
            var    random                = new Random(32);
            double result                = random.NextDouble();
            double targetProbability     = random.NextDouble();
            double targetReliability     = random.NextDouble();
            double calculatedProbability = random.NextDouble();
            double calculatedReliability = random.NextDouble();
            var    convergence           = random.NextEnumValue <CalculationConvergence>();

            var generalResult = new TestGeneralResultSubMechanismIllustrationPoint();

            // Call
            var output = new HydraulicBoundaryLocationCalculationOutput(result,
                                                                        targetProbability,
                                                                        targetReliability,
                                                                        calculatedProbability,
                                                                        calculatedReliability,
                                                                        convergence,
                                                                        generalResult);

            // Assert
            Assert.AreEqual(result, output.Result, output.Result.GetAccuracy());
            Assert.AreEqual(targetProbability, output.TargetProbability);
            Assert.AreEqual(targetReliability, output.TargetReliability, output.TargetReliability.GetAccuracy());
            Assert.AreEqual(calculatedProbability, output.CalculatedProbability);
            Assert.AreEqual(calculatedReliability, output.CalculatedReliability, output.CalculatedReliability.GetAccuracy());
            Assert.AreEqual(convergence, output.CalculationConvergence);
            Assert.AreSame(generalResult, output.GeneralResult);
            Assert.IsTrue(output.HasGeneralResult);
        }
Пример #5
0
        public void GetIllustrationPointControlItems_ViewWithData_ReturnsExpectedControlItems()
        {
            // Setup
            var topLevelIllustrationPoints = new[]
            {
                new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(),
                                                          "Regular",
                                                          new TestSubMechanismIllustrationPoint())
            };

            var generalResult = new TestGeneralResultSubMechanismIllustrationPoint(topLevelIllustrationPoints);
            var output        = new TestHydraulicBoundaryLocationCalculationOutput(generalResult);

            var calculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation())
            {
                Output = output
            };
            var calculations = new ObservableList <HydraulicBoundaryLocationCalculation>
            {
                calculation
            };

            TestHydraulicBoundaryCalculationsView view = ShowTestHydraulicBoundaryCalculationsView(calculations);

            // Call
            IEnumerable <IllustrationPointControlItem> actualControlItems =
                view.PublicGetIllustrationPointControlItems();

            // Assert
            IEnumerable <IllustrationPointControlItem> expectedControlItems =
                CreateControlItems(generalResult);

            CollectionAssert.AreEqual(expectedControlItems, actualControlItems,
                                      new IllustrationPointControlItemComparer());
        }
Пример #6
0
        private static ObservableList <HydraulicBoundaryLocationCalculation> GetTestHydraulicBoundaryLocationCalculations()
        {
            var topLevelIllustrationPoints = new[]
            {
                new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(),
                                                          "Regular",
                                                          new TestSubMechanismIllustrationPoint()),
                new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(),
                                                          "Test",
                                                          new TestSubMechanismIllustrationPoint())
            };

            var generalResult = new TestGeneralResultSubMechanismIllustrationPoint(topLevelIllustrationPoints);

            return(new ObservableList <HydraulicBoundaryLocationCalculation>
            {
                new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(1, "1", 1.0, 1.0)),
                new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(2, "2", 2.0, 2.0))
                {
                    Output = new TestHydraulicBoundaryLocationCalculationOutput(1.23)
                },
                new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(3, "3", 3.0, 3.0))
                {
                    InputParameters =
                    {
                        ShouldIllustrationPointsBeCalculated = true
                    }
                },
                new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(4, "4", 4.0, 4.0))
                {
                    InputParameters =
                    {
                        ShouldIllustrationPointsBeCalculated = true
                    },
                    Output = new TestHydraulicBoundaryLocationCalculationOutput(1.01, generalResult)
                }
            });
        }