public void ToString_DifferentClosingSituations_ReturnsCombinationOfWindDirectionAndClosingSituation()
        {
            // Setup
            string illustrationPointName         = string.Empty;
            var    subMechanismIllustrationPoint =
                new SubMechanismIllustrationPoint(illustrationPointName,
                                                  3,
                                                  Enumerable.Empty <SubMechanismIllustrationPointStochast>(),
                                                  Enumerable.Empty <IllustrationPointResult>());

            const string  closingSituation = "direction";
            WindDirection windDirection    = WindDirectionTestFactory.CreateTestWindDirection();
            var           context          = new TopLevelSubMechanismIllustrationPoint(windDirection,
                                                                                       closingSituation,
                                                                                       subMechanismIllustrationPoint);

            // Call
            var properties = new TopLevelSubMechanismIllustrationPointProperties(
                context,
                new[]
            {
                closingSituation,
                closingSituation,
                "Different situation"
            });

            // Assert
            string expectedStringValue = $"{windDirection.Name} ({closingSituation})";

            Assert.AreEqual(expectedStringValue, properties.ToString());
        }
        public void Create_ValidTopLevelSubMechanismIllustrationPoint_ReturnsEntityWithSubMechanismIllustrationPointEntity()
        {
            // Setup
            var random            = new Random(21);
            var illustrationPoint = new SubMechanismIllustrationPoint("Illustration point name",
                                                                      random.NextDouble(),
                                                                      Enumerable.Empty <SubMechanismIllustrationPointStochast>(),
                                                                      Enumerable.Empty <IllustrationPointResult>());

            var windDirection = new WindDirection("WindDirection Name", random.NextDouble());
            var topLevelSubMechanismIllustrationPoint = new TopLevelSubMechanismIllustrationPoint(windDirection,
                                                                                                  "Just a situation",
                                                                                                  illustrationPoint);
            int order = random.Next();

            // Call
            TopLevelSubMechanismIllustrationPointEntity entity =
                topLevelSubMechanismIllustrationPoint.Create(order);

            // Assert
            TestHelper.AssertAreEqualButNotSame(topLevelSubMechanismIllustrationPoint.ClosingSituation, entity.ClosingSituation);
            Assert.AreEqual(order, entity.Order);

            TestHelper.AssertAreEqualButNotSame(windDirection.Name, entity.WindDirectionName);
            Assert.AreEqual(windDirection.Angle, entity.WindDirectionAngle, windDirection.Angle.GetAccuracy());

            SubMechanismIllustrationPointEntity subMechanismIllustrationPointEntity = entity.SubMechanismIllustrationPointEntity;

            TestHelper.AssertAreEqualButNotSame(illustrationPoint.Name, subMechanismIllustrationPointEntity.Name);
            Assert.AreEqual(illustrationPoint.Beta, subMechanismIllustrationPointEntity.Beta, illustrationPoint.Beta.GetAccuracy());
            CollectionAssert.IsEmpty(subMechanismIllustrationPointEntity.IllustrationPointResultEntities);
            CollectionAssert.IsEmpty(subMechanismIllustrationPointEntity.SubMechanismIllustrationPointStochastEntities);
        }
示例#3
0
        public void GivenFullyConfiguredView_WhenSelectingCellInRow_ThenSelectionChangedAndPropagatedAccordingly()
        {
            // Given
            var mocks       = new MockRepository();
            var calculation = mocks.Stub <ICalculation>();

            mocks.ReplayAll();

            GeneralResult <TopLevelSubMechanismIllustrationPoint> generalResult = GetGeneralResultWithTwoTopLevelIllustrationPoints();
            var view = new GeneralResultSubMechanismIllustrationPointView(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);

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

            AssertIllustrationPointSelection(topLevelIllustrationPoint,
                                             topLevelIllustrationPoints.Select(ip => ip.ClosingSituation),
                                             view.Selection);
            mocks.VerifyAll();
        }
        public void GetStochastNames_TopLevelSubMechanismIllustrationPointWithSubMechanismIllustrationPointWithStochast_ReturnStochastNames()
        {
            // Setup
            var          random        = new Random(21);
            const string stochastNameA = "Stochast A";
            const string stochastNameB = "Stochast B";
            var          topLevelSubMechanismIllustrationPoint = new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(),
                                                                                                           "closing situation",
                                                                                                           new TestSubMechanismIllustrationPoint(new[]
            {
                new SubMechanismIllustrationPointStochast(stochastNameA,
                                                          "-",
                                                          random.NextDouble(),
                                                          random.NextDouble(),
                                                          random.NextDouble()),
                new SubMechanismIllustrationPointStochast(stochastNameB,
                                                          "-",
                                                          random.NextDouble(),
                                                          random.NextDouble(),
                                                          random.NextDouble())
            }));

            // Call
            IEnumerable <string> names = topLevelSubMechanismIllustrationPoint.GetStochastNames();

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                stochastNameA,
                stochastNameB
            }, names);
        }
示例#5
0
        public void Convert_ValidArguments_ExpectedProperties()
        {
            // Setup
            var random = new Random(21);
            var hydraRingWindDirection = new HydraRingWindDirection("Name", random.NextDouble());

            var hydraRingWindDirectionClosingSituation = new HydraRingWindDirectionClosingSituation(hydraRingWindDirection,
                                                                                                    "closing scenario");

            var hydraRingIllustrationPointResult = new HydraRingIllustrationPointResult("HydraIllustrationPointResult",
                                                                                        "-",
                                                                                        random.NextDouble());

            var hydraRingSubMechanismIllustrationPointStochast =
                new HydraRingSubMechanismIllustrationPointStochast("HydraSubMechanismIllustrationPointStochast",
                                                                   "-",
                                                                   random.NextDouble(),
                                                                   random.NextDouble(),
                                                                   random.NextDouble());

            var hydraRingSubMechanismIllustrationPoint = new HydraRingSubMechanismIllustrationPoint("name", new[]
            {
                hydraRingSubMechanismIllustrationPointStochast
            }, new[]
            {
                hydraRingIllustrationPointResult
            }, random.NextDouble());

            // Call
            TopLevelSubMechanismIllustrationPoint combination =
                TopLevelSubMechanismIllustrationPointConverter.Convert(
                    hydraRingWindDirectionClosingSituation, hydraRingSubMechanismIllustrationPoint);

            // Assert
            WindDirection windDirection = combination.WindDirection;

            Assert.AreEqual(hydraRingWindDirection.Angle, windDirection.Angle, windDirection.Angle.GetAccuracy());
            Assert.AreEqual(hydraRingWindDirection.Name, windDirection.Name);

            Assert.AreEqual(hydraRingWindDirectionClosingSituation.ClosingSituation, combination.ClosingSituation);

            SubMechanismIllustrationPoint subMechanismIllustrationPoint = combination.SubMechanismIllustrationPoint;

            Assert.AreEqual(hydraRingSubMechanismIllustrationPoint.Beta, subMechanismIllustrationPoint.Beta, subMechanismIllustrationPoint.Beta.GetAccuracy());
            Assert.AreEqual(hydraRingSubMechanismIllustrationPoint.Name, subMechanismIllustrationPoint.Name);

            IllustrationPointResult illustrationPointResult = subMechanismIllustrationPoint.IllustrationPointResults.Single();

            Assert.AreEqual(hydraRingIllustrationPointResult.Description, illustrationPointResult.Description);
            Assert.AreEqual(hydraRingIllustrationPointResult.Value, illustrationPointResult.Value, illustrationPointResult.Value.GetAccuracy());

            SubMechanismIllustrationPointStochast stochast = subMechanismIllustrationPoint.Stochasts.Single();

            Assert.AreEqual(hydraRingSubMechanismIllustrationPointStochast.Alpha, stochast.Alpha, stochast.Alpha.GetAccuracy());
            Assert.AreEqual(hydraRingSubMechanismIllustrationPointStochast.Duration, stochast.Duration, stochast.Duration.GetAccuracy());
            Assert.AreEqual(hydraRingSubMechanismIllustrationPointStochast.Name, stochast.Name);
            Assert.AreEqual(hydraRingSubMechanismIllustrationPointStochast.Unit, stochast.Unit);
            Assert.AreEqual(hydraRingSubMechanismIllustrationPointStochast.Realization, stochast.Realization, stochast.Realization.GetAccuracy());
        }
示例#6
0
        private static void AssertIllustrationPointSelection(TopLevelSubMechanismIllustrationPoint expectedSelection,
                                                             IEnumerable <string> expectedClosingSituations,
                                                             object selection)
        {
            var illustrationPointSelection = selection as SelectedTopLevelSubMechanismIllustrationPoint;

            Assert.IsNotNull(illustrationPointSelection);
            Assert.AreSame(expectedSelection, illustrationPointSelection.TopLevelSubMechanismIllustrationPoint);
            CollectionAssert.AreEqual(expectedClosingSituations, illustrationPointSelection.ClosingSituations);
        }
        public void ConvertToGeneralResultTopLevelSubMechanismIllustrationPoint_HydraGeneralResultWithSubMechanismIllustrationPointsOnly_ExpectedProperties()
        {
            // Setup
            const string closingSituation = "Closing situation";

            var random = new Random(21);
            var hydraRingWindDirection = new HydraRingWindDirection("SSE", random.NextDouble());
            var hydraRingWindDirectionClosingSituation = new HydraRingWindDirectionClosingSituation(
                hydraRingWindDirection, closingSituation);

            var hydraRingIllustrationPoint = new HydraRingSubMechanismIllustrationPoint(
                "Illustration Point",
                Enumerable.Empty <HydraRingSubMechanismIllustrationPointStochast>(),
                Enumerable.Empty <HydraRingIllustrationPointResult>(),
                random.NextDouble());
            var hydraRingIllustrationTreeNode = new HydraRingIllustrationPointTreeNode(hydraRingIllustrationPoint);

            var governingHydraWindDirection = new HydraRingWindDirection("Name", random.NextDouble());
            var hydraGeneralResult          = new HydraRingGeneralResult(
                random.NextDouble(),
                governingHydraWindDirection,
                Enumerable.Empty <HydraRingStochast>(),
                new Dictionary <HydraRingWindDirectionClosingSituation, HydraRingIllustrationPointTreeNode>
            {
                {
                    hydraRingWindDirectionClosingSituation, hydraRingIllustrationTreeNode
                }
            });

            // Call
            GeneralResult <TopLevelSubMechanismIllustrationPoint> generalResult =
                GeneralResultConverter.ConvertToGeneralResultTopLevelSubMechanismIllustrationPoint(hydraGeneralResult);

            // Assert
            WindDirection generalResultGoverningWindDirection = generalResult.GoverningWindDirection;

            AssertWindDirection(governingHydraWindDirection, generalResultGoverningWindDirection);

            CollectionAssert.IsEmpty(generalResult.Stochasts);

            TopLevelSubMechanismIllustrationPoint combination = generalResult.TopLevelIllustrationPoints.Single();

            AssertWindDirection(hydraRingWindDirection, combination.WindDirection);
            Assert.AreEqual(closingSituation, combination.ClosingSituation);

            SubMechanismIllustrationPoint subMechanismIllustrationPoint = combination.SubMechanismIllustrationPoint;

            Assert.AreEqual(hydraRingIllustrationPoint.Name, subMechanismIllustrationPoint.Name);
            Assert.AreEqual(hydraRingIllustrationPoint.Beta, subMechanismIllustrationPoint.Beta, subMechanismIllustrationPoint.Beta.GetAccuracy());
            CollectionAssert.IsEmpty(subMechanismIllustrationPoint.Stochasts);
            CollectionAssert.IsEmpty(subMechanismIllustrationPoint.IllustrationPointResults);
        }
示例#8
0
        private static void AssertTopLevelSubMechanismIllustrationPoint(
            TopLevelSubMechanismIllustrationPointEntity illustrationPointEntity,
            TopLevelSubMechanismIllustrationPoint readTopLevelSubMechanismIllustrationPoint)
        {
            Assert.AreEqual(illustrationPointEntity.ClosingSituation, readTopLevelSubMechanismIllustrationPoint.ClosingSituation);

            WindDirection actualWindDirection = readTopLevelSubMechanismIllustrationPoint.WindDirection;

            Assert.AreEqual(illustrationPointEntity.WindDirectionName, actualWindDirection.Name);
            Assert.AreEqual(illustrationPointEntity.WindDirectionAngle, actualWindDirection.Angle, actualWindDirection.Angle);

            Assert.IsNotNull(readTopLevelSubMechanismIllustrationPoint.SubMechanismIllustrationPoint);
        }
        public void Clone_Always_ReturnNewInstanceWithCopiedValues()
        {
            // Setup
            var original = new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(),
                                                                     "Random closing situation",
                                                                     new TestSubMechanismIllustrationPoint());

            // Call
            object clone = original.Clone();

            // Assert
            CoreCloneAssert.AreObjectClones(original, clone, CommonCloneAssert.AreClones);
        }
        public void Constructor_ValidArguments_ReturnsExpectedValues()
        {
            // Setup
            TopLevelSubMechanismIllustrationPoint topLevelSubMechanismIllustrationPoint = CreateTopLevelSubMechanismIllustrationPoint();
            IEnumerable <string> closingSituations = Enumerable.Empty <string>();

            // Call
            var selectedTopLevelSubMechanismIllustrationPoint = new SelectedTopLevelSubMechanismIllustrationPoint(topLevelSubMechanismIllustrationPoint,
                                                                                                                  closingSituations);

            // Assert
            Assert.AreSame(topLevelSubMechanismIllustrationPoint, selectedTopLevelSubMechanismIllustrationPoint.TopLevelSubMechanismIllustrationPoint);
            Assert.AreSame(closingSituations, selectedTopLevelSubMechanismIllustrationPoint.ClosingSituations);
        }
        public void Constructor_ClosingSituationsNull_ThrowsArgumentNullException()
        {
            // Setup
            var data = new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(),
                                                                 string.Empty,
                                                                 new TestSubMechanismIllustrationPoint());

            // Call
            void Call() => new TopLevelSubMechanismIllustrationPointProperties(data, null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("closingSituations", exception.ParamName);
        }
        /// <summary>
        /// Creates a new instance of <see cref="SelectedTopLevelSubMechanismIllustrationPoint"/>.
        /// </summary>
        /// <param name="topLevelSubMechanismIllustrationPoint">The top level sub mechanism illustration point.</param>
        /// <param name="closingSituations">The closing situations that are present.</param>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        public SelectedTopLevelSubMechanismIllustrationPoint(TopLevelSubMechanismIllustrationPoint topLevelSubMechanismIllustrationPoint,
                                                             IEnumerable <string> closingSituations)
        {
            if (topLevelSubMechanismIllustrationPoint == null)
            {
                throw new ArgumentNullException(nameof(topLevelSubMechanismIllustrationPoint));
            }

            if (closingSituations == null)
            {
                throw new ArgumentNullException(nameof(closingSituations));
            }

            TopLevelSubMechanismIllustrationPoint = topLevelSubMechanismIllustrationPoint;
            ClosingSituations = closingSituations;
        }
        public void CreateInstance_SelectedTopLevelSubMechanismIllustrationPoint_ReturnsTopLevelSubMechanismIllustrationPointProperties()
        {
            // Setup
            var topLevelSubMechanismIllustrationPoint = new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(),
                                                                                                  string.Empty,
                                                                                                  new TestSubMechanismIllustrationPoint());

            var selectedTopLevelSubMechanismIllustrationPoint = new SelectedTopLevelSubMechanismIllustrationPoint(topLevelSubMechanismIllustrationPoint,
                                                                                                                  Enumerable.Empty <string>());

            // Call
            IObjectProperties objectProperties = info.CreateInstance(selectedTopLevelSubMechanismIllustrationPoint);

            // Assert
            Assert.IsInstanceOf <TopLevelSubMechanismIllustrationPointProperties>(objectProperties);
            Assert.AreSame(topLevelSubMechanismIllustrationPoint, objectProperties.Data);
        }
        public void Constructor_ValidArguments_ReturnsExpectedProperties()
        {
            // Setup
            const string  closingScenario = "closing scenario";
            WindDirection windDirection   = WindDirectionTestFactory.CreateTestWindDirection();
            var           subMechanismIllustrationPoint = new TestSubMechanismIllustrationPoint();

            // Call
            var windDirectionClosingScenarioIllustrationPoint =
                new TopLevelSubMechanismIllustrationPoint(windDirection, closingScenario, subMechanismIllustrationPoint);

            // Assert
            Assert.IsInstanceOf <TopLevelIllustrationPointBase>(windDirectionClosingScenarioIllustrationPoint);
            Assert.AreEqual(closingScenario, windDirectionClosingScenarioIllustrationPoint.ClosingSituation);
            Assert.AreSame(windDirection, windDirectionClosingScenarioIllustrationPoint.WindDirection);
            Assert.AreSame(subMechanismIllustrationPoint, windDirectionClosingScenarioIllustrationPoint.SubMechanismIllustrationPoint);
        }
示例#15
0
        private static void AssertIllustrationPointControlItems(GeneralResult <TopLevelSubMechanismIllustrationPoint> generalResult, IllustrationPointsControl illustrationPointsControl)
        {
            TopLevelSubMechanismIllustrationPoint topLevelSubMechanismIllustrationPoint1 = generalResult.TopLevelIllustrationPoints.ElementAt(0);
            TopLevelSubMechanismIllustrationPoint topLevelSubMechanismIllustrationPoint2 = generalResult.TopLevelIllustrationPoints.ElementAt(1);
            var expectedControlItems = new[]
            {
                new IllustrationPointControlItem(topLevelSubMechanismIllustrationPoint1,
                                                 topLevelSubMechanismIllustrationPoint1.WindDirection.Name,
                                                 topLevelSubMechanismIllustrationPoint1.ClosingSituation,
                                                 topLevelSubMechanismIllustrationPoint1.SubMechanismIllustrationPoint.Stochasts,
                                                 topLevelSubMechanismIllustrationPoint1.SubMechanismIllustrationPoint.Beta),
                new IllustrationPointControlItem(topLevelSubMechanismIllustrationPoint2,
                                                 topLevelSubMechanismIllustrationPoint2.WindDirection.Name,
                                                 topLevelSubMechanismIllustrationPoint2.ClosingSituation,
                                                 topLevelSubMechanismIllustrationPoint2.SubMechanismIllustrationPoint.Stochasts,
                                                 topLevelSubMechanismIllustrationPoint2.SubMechanismIllustrationPoint.Beta)
            };

            CollectionAssert.AreEqual(expectedControlItems, illustrationPointsControl.Data, new IllustrationPointControlItemComparer());
        }
示例#16
0
        private static GeneralResult <TopLevelSubMechanismIllustrationPoint> GetGeneralResultWithTwoTopLevelIllustrationPoints()
        {
            var topLevelSubMechanismIllustrationPoint1 =
                new TopLevelSubMechanismIllustrationPoint(
                    WindDirectionTestFactory.CreateTestWindDirection(),
                    "Closing situation 1",
                    new TestSubMechanismIllustrationPoint());

            var topLevelSubMechanismIllustrationPoint2 =
                new TopLevelSubMechanismIllustrationPoint(
                    WindDirectionTestFactory.CreateTestWindDirection(),
                    "Closing situation 2",
                    new TestSubMechanismIllustrationPoint());

            return(new GeneralResult <TopLevelSubMechanismIllustrationPoint>(WindDirectionTestFactory.CreateTestWindDirection(),
                                                                             Enumerable.Empty <Stochast>(),
                                                                             new[]
            {
                topLevelSubMechanismIllustrationPoint1,
                topLevelSubMechanismIllustrationPoint2
            }));
        }
        public void Read_ValidEntity_ReturnsTopLevelSubMechanismIllustrationPoint()
        {
            // Setup
            var random = new Random(21);

            var subMechanismIllustrationPointEntity = new SubMechanismIllustrationPointEntity
            {
                Name = "Illustration point name",
                Beta = random.NextDouble()
            };

            var entity = new TopLevelSubMechanismIllustrationPointEntity
            {
                ClosingSituation   = "closingSituation",
                WindDirectionName  = "WindDirectionName",
                WindDirectionAngle = random.NextDouble(),
                SubMechanismIllustrationPointEntity = subMechanismIllustrationPointEntity
            };

            // Call
            TopLevelSubMechanismIllustrationPoint topLevelSubMechanismIllustrationPoint = entity.Read();

            // Assert
            Assert.AreEqual(entity.ClosingSituation, topLevelSubMechanismIllustrationPoint.ClosingSituation);

            WindDirection actualWindDirection = topLevelSubMechanismIllustrationPoint.WindDirection;

            Assert.AreEqual(entity.WindDirectionName, actualWindDirection.Name);
            Assert.AreEqual(entity.WindDirectionAngle, actualWindDirection.Angle,
                            actualWindDirection.Angle.GetAccuracy());

            SubMechanismIllustrationPoint actualIllustrationPoint = topLevelSubMechanismIllustrationPoint.SubMechanismIllustrationPoint;

            Assert.AreEqual(subMechanismIllustrationPointEntity.Name, actualIllustrationPoint.Name);
            Assert.AreEqual(subMechanismIllustrationPointEntity.Beta, actualIllustrationPoint.Beta,
                            actualIllustrationPoint.Beta.GetAccuracy());
            CollectionAssert.IsEmpty(actualIllustrationPoint.Stochasts);
            CollectionAssert.IsEmpty(actualIllustrationPoint.IllustrationPointResults);
        }
示例#18
0
        /// <summary>
        /// Creates a <see cref="TopLevelSubMechanismIllustrationPointEntity"/>
        /// based on the information of <paramref name="topLevelSubMechanismIllustrationPoint"/>.
        /// </summary>
        /// <param name="topLevelSubMechanismIllustrationPoint">The top level illustration point
        /// to create a database entity for.</param>
        /// <param name="order">The index at which <paramref name="topLevelSubMechanismIllustrationPoint"/>
        /// resides within its parent.</param>
        /// <returns>A <see cref="TopLevelSubMechanismIllustrationPointEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when
        /// <paramref name="topLevelSubMechanismIllustrationPoint"/> is <c>null</c>.</exception>
        internal static TopLevelSubMechanismIllustrationPointEntity Create(
            this TopLevelSubMechanismIllustrationPoint topLevelSubMechanismIllustrationPoint,
            int order)
        {
            if (topLevelSubMechanismIllustrationPoint == null)
            {
                throw new ArgumentNullException(nameof(topLevelSubMechanismIllustrationPoint));
            }

            WindDirection windDirection = topLevelSubMechanismIllustrationPoint.WindDirection;

            return(new TopLevelSubMechanismIllustrationPointEntity
            {
                ClosingSituation = topLevelSubMechanismIllustrationPoint.ClosingSituation.DeepClone(),
                WindDirectionName = windDirection.Name.DeepClone(),
                WindDirectionAngle = windDirection.Angle,
                SubMechanismIllustrationPointEntity =
                    topLevelSubMechanismIllustrationPoint.SubMechanismIllustrationPoint
                    .Create(0),
                Order = order
            });
        }
        public void GetProperties_ValidData_ReturnsExpectedValues()
        {
            var    random    = new Random(21);
            double beta      = random.NextDouble();
            var    stochasts = new[]
            {
                new SubMechanismIllustrationPointStochast("some name", "-", random.NextDouble(), random.NextDouble(), random.NextDouble())
            };
            var illustrationPointResults = new[]
            {
                new IllustrationPointResult("some description", "-", random.NextDouble())
            };

            const string illustrationPointName         = "name";
            var          subMechanismIllustrationPoint = new SubMechanismIllustrationPoint(illustrationPointName,
                                                                                           beta,
                                                                                           stochasts,
                                                                                           illustrationPointResults);

            const string closingSituation  = "closingSituation";
            const string windDirectionName = "windDirection";
            var          illustrationPoint = new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(windDirectionName),
                                                                                       closingSituation,
                                                                                       subMechanismIllustrationPoint);

            // Call
            var properties = new TopLevelSubMechanismIllustrationPointProperties(illustrationPoint, Enumerable.Empty <string>());

            // Assert
            Assert.AreEqual(illustrationPointName, properties.Name);
            Assert.AreEqual(windDirectionName, properties.WindDirection);
            Assert.AreEqual(closingSituation, properties.ClosingSituation);
            CollectionAssert.AreEqual(subMechanismIllustrationPoint.Stochasts, properties.AlphaValues);
            CollectionAssert.AreEqual(subMechanismIllustrationPoint.Stochasts, properties.Durations);

            Assert.AreSame(illustrationPoint.SubMechanismIllustrationPoint,
                           properties.SubMechanismIllustrationPointValues.Data);
        }
        public void GetProperties_SameClosingSituations_ReturnsExpectedAttributeValues()
        {
            // Setup
            var context = new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(),
                                                                    "closingSituation",
                                                                    new TestSubMechanismIllustrationPoint());
            const string closingSituation = "Closing Situation";

            // Call
            var properties = new TopLevelSubMechanismIllustrationPointProperties(
                context,
                new[]
            {
                closingSituation,
                closingSituation
            });

            // Assert
            TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true);

            Assert.IsInstanceOf <ExpandableObjectConverter>(classTypeConverter);

            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(7, dynamicProperties.Count);

            const string generalCategory = "Algemeen";

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[namePropertyIndex],
                                                                            generalCategory,
                                                                            "Naam",
                                                                            "De naam van dit berekende illustratiepunt.",
                                                                            true);

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[calculatedProbabilityPropertyIndex],
                                                                            generalCategory,
                                                                            "Berekende kans [-]",
                                                                            "De berekende kans van voorkomen van het berekende resultaat.",
                                                                            true);

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[calculatedReliabilityPropertyIndex],
                                                                            generalCategory,
                                                                            "Betrouwbaarheidsindex berekende kans [-]",
                                                                            "Betrouwbaarheidsindex van de berekende kans van voorkomen van het berekende resultaat.",
                                                                            true);

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(dynamicProperties[windDirectionNamePropertyIndex],
                                                                            generalCategory,
                                                                            "Windrichting",
                                                                            "De windrichting waarvoor dit illlustratiepunt is berekend.",
                                                                            true);

            TestHelper.AssertTypeConverter <TopLevelSubMechanismIllustrationPointProperties, KeyValueExpandableArrayConverter>(nameof(TopLevelSubMechanismIllustrationPointProperties.AlphaValues));
            PropertyDescriptor alphaValuesProperty = dynamicProperties[alphaValuesPropertyIndex];

            Assert.NotNull(alphaValuesProperty.Attributes[typeof(KeyValueElementAttribute)]);
            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(alphaValuesProperty,
                                                                            generalCategory,
                                                                            "Invloedscoëfficiënten [-]",
                                                                            "Berekende invloedscoëfficiënten voor alle beschouwde stochasten.",
                                                                            true);

            TestHelper.AssertTypeConverter <TopLevelSubMechanismIllustrationPointProperties, KeyValueExpandableArrayConverter>(nameof(TopLevelSubMechanismIllustrationPointProperties.Durations));
            PropertyDescriptor durationsProperty = dynamicProperties[durationsPropertyIndex];

            Assert.NotNull(durationsProperty.Attributes[typeof(KeyValueElementAttribute)]);
            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(durationsProperty,
                                                                            generalCategory,
                                                                            "Tijdsduren [uur]",
                                                                            "Tijdsduren waarop de stochasten betrekking hebben.",
                                                                            true);

            PropertyDescriptor illustrationPointValuesProperties = dynamicProperties[illustrationPointValuesPropertyIndex];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(illustrationPointValuesProperties,
                                                                            generalCategory,
                                                                            "Waarden in het illustratiepunt",
                                                                            "",
                                                                            true);
        }
示例#21
0
 /// <summary>
 /// Method that asserts whether <paramref name="original"/> and <paramref name="clone"/>
 /// are clones.
 /// </summary>
 /// <param name="original">The original object.</param>
 /// <param name="clone">The cloned object.</param>
 /// <exception cref="AssertionException">Thrown when <paramref name="original"/> and
 /// <paramref name="clone"/> are not clones.</exception>
 public static void AreClones(TopLevelSubMechanismIllustrationPoint original, TopLevelSubMechanismIllustrationPoint clone)
 {
     AreClones((TopLevelIllustrationPointBase)original, clone);
     CoreCloneAssert.AreObjectClones(original.SubMechanismIllustrationPoint, clone.SubMechanismIllustrationPoint, AreClones);
 }