示例#1
0
        public void Constructor_ValidArguments_ExpectedValues()
        {
            // Setup
            var          source            = new TestTopLevelIllustrationPoint();
            const string windDirectionName = "Name";
            const string closingSituation  = "Closing situation";

            const int nrOfDecimals = 10;
            var       beta         = new RoundedDouble(nrOfDecimals, 123.789);

            var controlItem = new IllustrationPointControlItem(source,
                                                               windDirectionName,
                                                               closingSituation,
                                                               Enumerable.Empty <Stochast>(),
                                                               beta);

            // Call
            var row = new IllustrationPointRow(controlItem);

            // Assert
            TestHelper.AssertTypeConverter <IllustrationPointRow, NoProbabilityValueDoubleConverter>(
                nameof(IllustrationPointRow.Probability));

            TestHelper.AssertTypeConverter <IllustrationPointRow, NoValueRoundedDoubleConverter>(
                nameof(IllustrationPointRow.Reliability));

            double expectedProbability = StatisticsConverter.ReliabilityToProbability(controlItem.Beta);

            Assert.AreSame(controlItem, row.IllustrationPointControlItem);
            Assert.AreEqual(controlItem.WindDirectionName, row.WindDirection);
            Assert.AreEqual(controlItem.ClosingSituation, row.ClosingSituation);
            Assert.AreEqual(expectedProbability, row.Probability);
            Assert.AreEqual(beta, row.Reliability);
            Assert.AreEqual(nrOfDecimals, row.Reliability.NumberOfDecimalPlaces);
        }
示例#2
0
        public void GivenFullyConfiguredView_WhenSelectingCellInRow_ThenSelectionChangedAndPropagatedAccordingly()
        {
            // Given
            var mocks       = new MockRepository();
            var calculation = mocks.Stub <ICalculation>();

            mocks.ReplayAll();

            GeneralResult <TestTopLevelIllustrationPoint> generalResult = GetGeneralResultWithTwoTopLevelIllustrationPoints();
            var view = new TestGeneralResultIllustrationPointView(calculation, () => generalResult);

            ShowTestView(view);

            var selectionChangedCount = 0;

            view.SelectionChanged += (sender, args) => selectionChangedCount++;

            DataGridView dataGridView = ControlTestHelper.GetDataGridView(testForm, "DataGridView");

            // When
            dataGridView.CurrentCell = dataGridView.Rows[1].Cells[0];
            EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(0, 0));

            // Then
            Assert.AreEqual(1, selectionChangedCount);

            TestTopLevelIllustrationPoint[] topLevelIllustrationPoints = generalResult.TopLevelIllustrationPoints.ToArray();
            TestTopLevelIllustrationPoint   topLevelIllustrationPoint  = topLevelIllustrationPoints.ElementAt(1);

            Assert.AreSame(topLevelIllustrationPoint, view.Selection);
            mocks.VerifyAll();
        }
        public void Constructor_ValidArguments_ReturnsExpectedProperties()
        {
            // Setup
            const string windDirectionName = "Wind direction name";
            const string closingSituation  = "Closing situation";

            const int nrOfDecimals = 10;
            var       beta         = new RoundedDouble(nrOfDecimals, 13.37);

            var source = new TestTopLevelIllustrationPoint();
            IEnumerable <Stochast> stochasts = Enumerable.Empty <Stochast>();

            // Call
            var item = new IllustrationPointControlItem(source,
                                                        windDirectionName,
                                                        closingSituation,
                                                        stochasts,
                                                        beta);

            // Assert
            Assert.AreSame(source, item.Source);
            Assert.AreEqual(nrOfDecimals, item.Beta.NumberOfDecimalPlaces);
            Assert.AreEqual(beta, item.Beta, item.Beta.GetAccuracy());
            Assert.AreSame(stochasts, item.Stochasts);
        }
示例#4
0
        public void Constructor_TopLevelIllustrationPointsWindDirectionClosingSituationCombinationNotUnique_ThrowArgumentException()
        {
            // Setup
            WindDirection          windDirection = WindDirectionTestFactory.CreateTestWindDirection();
            IEnumerable <Stochast> stochasts     = Enumerable.Empty <Stochast>();
            var topLevelIllustrationPoint        = new TestTopLevelIllustrationPoint("not unique");
            IEnumerable <TopLevelIllustrationPointBase> topLevelIllustrationPoints = new[]
            {
                topLevelIllustrationPoint,
                topLevelIllustrationPoint
            };

            // Call
            TestDelegate test = () => new GeneralResult <TopLevelIllustrationPointBase>(windDirection,
                                                                                        stochasts,
                                                                                        topLevelIllustrationPoints);

            // Assert
            const string expectedMessage = "Een of meerdere illustratiepunten hebben dezelfde combinatie van keringsituatie en windrichting.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(test, expectedMessage);
        }
示例#5
0
        private static void AssertIllustrationPointControlItems(GeneralResult <TestTopLevelIllustrationPoint> generalResult, IllustrationPointsControl illustrationPointsControl)
        {
            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());
        }