Exemple #1
0
        public void Constructor_ValidData_PropertiesHaveExpectedAttributeValues()
        {
            // Setup
            MacroStabilityInwardsPhreaticLine phreaticLine = MacroStabilityInwardsTestDataFactory.CreateMacroStabilityInwardsPhreaticLine();

            // Call
            var properties = new MacroStabilityInwardsPhreaticLineProperties(phreaticLine);

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(2, dynamicProperties.Count);

            const string waterStressesCategoryName = "Waterspanningen";

            PropertyDescriptor nameProperty = dynamicProperties[0];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty,
                                                                            waterStressesCategoryName,
                                                                            "Naam",
                                                                            "De naam van de lijn.",
                                                                            true);

            PropertyDescriptor geometryProperty = dynamicProperties[1];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(geometryProperty,
                                                                            waterStressesCategoryName,
                                                                            "Geometrie",
                                                                            "De geometrie van de lijn.",
                                                                            true);
        }
Exemple #2
0
        private static PersistableHeadLine Create(MacroStabilityInwardsPhreaticLine phreaticLine, IdFactory idFactory)
        {
            var headLine = new PersistableHeadLine
            {
                Id     = idFactory.Create(),
                Label  = phreaticLine.Name,
                Points = phreaticLine.Geometry.Select(point => new PersistablePoint(point.X, point.Y)).ToArray()
            };

            createdHeadLines.Add(phreaticLine, headLine);

            return(headLine);
        }
Exemple #3
0
        public void ToString_Always_ReturnsName()
        {
            // Setup
            const string expectedName = "PL2";
            var          phreaticLine = new MacroStabilityInwardsPhreaticLine(expectedName, Enumerable.Empty <Point2D>());
            var          properties   = new MacroStabilityInwardsPhreaticLineProperties(phreaticLine);

            // Call
            var name = properties.ToString();

            // Assert
            Assert.AreEqual(name, expectedName);
        }
Exemple #4
0
        public void Constructor_ValidPhreaticLine_ExpectedValues()
        {
            // Setup
            MacroStabilityInwardsPhreaticLine phreaticLine = MacroStabilityInwardsTestDataFactory.CreateMacroStabilityInwardsPhreaticLine();

            // Call
            var properties = new MacroStabilityInwardsPhreaticLineProperties(phreaticLine);

            // Assert
            Assert.IsInstanceOf <ObjectProperties <MacroStabilityInwardsPhreaticLine> >(properties);
            TestHelper.AssertTypeConverter <MacroStabilityInwardsPhreaticLineProperties, ExpandableReadOnlyArrayConverter>(
                nameof(MacroStabilityInwardsPhreaticLineProperties.Geometry));
            Assert.AreSame(phreaticLine, properties.Data);
        }
Exemple #5
0
        public void Create_WithValidData_ReturnsPersistableWaternetCollection()
        {
            // Setup
            var phreaticLine1 = new MacroStabilityInwardsPhreaticLine("Phreatic Line", Enumerable.Empty <Point2D>());
            var waternetLine1 = new MacroStabilityInwardsWaternetLine("Waternet Line", Enumerable.Empty <Point2D>(), phreaticLine1);
            var phreaticLine2 = new MacroStabilityInwardsPhreaticLine("Phreatic Line", Enumerable.Empty <Point2D>());
            var waternetLine2 = new MacroStabilityInwardsWaternetLine("Waternet Line", Enumerable.Empty <Point2D>(), phreaticLine2);

            var dailyWaternet = new MacroStabilityInwardsWaternet(new[]
            {
                phreaticLine1
            }, new[]
            {
                waternetLine1
            });

            var extremeWaternet = new MacroStabilityInwardsWaternet(new[]
            {
                phreaticLine2
            }, new[]
            {
                waternetLine2
            });

            var idFactory = new IdFactory();
            var registry  = new MacroStabilityInwardsExportRegistry();

            // Call
            IEnumerable <PersistableWaternet> persistableWaternets = PersistableWaternetFactory.Create(dailyWaternet, extremeWaternet, new GeneralMacroStabilityInwardsInput(), idFactory, registry);

            // Assert
            PersistableDataModelTestHelper.AssertWaternets(new[]
            {
                dailyWaternet,
                extremeWaternet
            }, persistableWaternets);

            var stages = new[]
            {
                MacroStabilityInwardsExportStageType.Daily,
                MacroStabilityInwardsExportStageType.Extreme
            };

            Assert.AreEqual(2, registry.Waternets.Count);

            for (var i = 0; i < stages.Length; i++)
            {
                Assert.AreEqual(registry.Waternets[stages[i]], persistableWaternets.ElementAt(i).Id);
            }
        }
Exemple #6
0
        public void GetProperties_WithData_ReturnExpectedValues()
        {
            // Setup
            var random       = new Random(21);
            var phreaticLine = new MacroStabilityInwardsPhreaticLine("PL1",
                                                                     new[]
            {
                new Point2D(random.NextDouble(), random.NextDouble()),
                new Point2D(random.NextDouble(), random.NextDouble())
            });

            // Call
            var properties = new MacroStabilityInwardsPhreaticLineProperties(phreaticLine);

            // Assert
            Assert.AreEqual(phreaticLine.Name, properties.Name);
            CollectionAssert.AreEqual(phreaticLine.Geometry, properties.Geometry);
        }
        /// <summary>
        /// Asserts whether the <see cref="MacroStabilityInwardsWaternet"/> contains the data
        /// that is representative for the <paramref name="originalWaternets"/>.
        /// </summary>
        /// <param name="originalWaternets">The Waternets that contain the original data.</param>
        /// <param name="actualWaternets">The <see cref="PersistableWaternet"/>
        /// that needs to be asserted.</param>
        /// <exception cref="AssertionException">Thrown when the data in <paramref name="actualWaternets"/>
        /// is not correct.</exception>
        public static void AssertWaternets(IEnumerable <MacroStabilityInwardsWaternet> originalWaternets, IEnumerable <PersistableWaternet> actualWaternets)
        {
            Assert.AreEqual(originalWaternets.Count(), actualWaternets.Count());

            for (var i = 0; i < originalWaternets.Count(); i++)
            {
                MacroStabilityInwardsWaternet originalWaternet = originalWaternets.ElementAt(i);
                PersistableWaternet           actualWaternet   = actualWaternets.ElementAt(i);

                Assert.IsNotNull(actualWaternet.Id);
                Assert.AreEqual(9.81, actualWaternet.UnitWeightWater);

                PersistableHeadLine firstHeadLine = actualWaternet.HeadLines.FirstOrDefault();
                Assert.AreEqual(actualWaternet.PhreaticLineId, firstHeadLine?.Id);

                Assert.AreEqual(originalWaternet.PhreaticLines.Count(), actualWaternet.HeadLines.Count());

                for (var j = 0; j < originalWaternet.PhreaticLines.Count(); j++)
                {
                    MacroStabilityInwardsPhreaticLine phreaticLine = originalWaternet.PhreaticLines.ElementAt(j);
                    PersistableHeadLine headLine = actualWaternet.HeadLines.ElementAt(j);

                    Assert.IsNotNull(headLine.Id);
                    Assert.AreEqual(phreaticLine.Name, headLine.Label);
                    CollectionAssert.AreEqual(phreaticLine.Geometry.Select(p => new PersistablePoint(p.X, p.Y)), headLine.Points);
                }

                Assert.AreEqual(originalWaternet.WaternetLines.Count(), actualWaternet.ReferenceLines.Count());

                for (var j = 0; j < originalWaternet.WaternetLines.Count(); j++)
                {
                    MacroStabilityInwardsWaternetLine waternetLine  = originalWaternet.WaternetLines.ElementAt(j);
                    PersistableReferenceLine          referenceLine = actualWaternet.ReferenceLines.ElementAt(j);

                    Assert.IsNotNull(referenceLine.Id);
                    Assert.AreEqual(waternetLine.Name, referenceLine.Label);
                    CollectionAssert.AreEqual(waternetLine.Geometry.Select(p => new PersistablePoint(p.X, p.Y)), referenceLine.Points);

                    Assert.AreEqual(firstHeadLine.Id, referenceLine.TopHeadLineId);
                    Assert.AreEqual(firstHeadLine.Id, referenceLine.BottomHeadLineId);
                }
            }
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            var phreaticLine = new MacroStabilityInwardsPhreaticLine("Phreatic Line", Enumerable.Empty <Point2D>());
            var waternetLine = new MacroStabilityInwardsWaternetLine("Waternet Line", Enumerable.Empty <Point2D>(), phreaticLine);

            // Call
            var waternet = new MacroStabilityInwardsWaternet(new[]
            {
                phreaticLine
            }, new[]
            {
                waternetLine
            });

            // Assert
            Assert.AreSame(phreaticLine, waternet.PhreaticLines.Single());
            Assert.AreSame(waternetLine, waternet.WaternetLines.Single());
        }
        public void Constructor_ExpectedValues()
        {
            // Setup
            const string name     = "<some name>";
            var          geometry = new List <Point2D>
            {
                new Point2D(0.0, 0.0),
                new Point2D(15.0, 15.0)
            };

            // Call
            var phreaticLine = new MacroStabilityInwardsPhreaticLine(name, geometry);

            // Assert
            Assert.AreEqual(name, phreaticLine.Name);
            CollectionAssert.AreEqual(new List <Point2D>
            {
                new Point2D(0.0, 0.0),
                new Point2D(15.0, 15.0)
            }, phreaticLine.Geometry);
        }
Exemple #10
0
 /// <summary>
 /// Create points of the phreatic line in 2D space based on the provided <paramref name="phreaticLine"/>.
 /// </summary>
 /// <param name="phreaticLine">The phreatic line to create the points for.</param>
 /// <returns>A collection of points in 2D space or an empty collection when <paramref name="phreaticLine"/>
 /// is <c>null</c>.</returns>
 public static IEnumerable <Point2D> CreatePhreaticLinePoints(MacroStabilityInwardsPhreaticLine phreaticLine)
 {
     return(phreaticLine?.Geometry ?? new Point2D[0]);
 }