public void ReadReferenceLinesMetas_NoFilePath_ThrowArgumentException(string invalidFilePath)
        {
            // Call
            TestDelegate call = () => ReferenceLinesMetaReader.ReadReferenceLinesMetas(invalidFilePath);

            // Assert
            string expectedMessage = $"Fout bij het lezen van bestand '{invalidFilePath}': bestandspad mag niet leeg of ongedefinieerd zijn.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(call, expectedMessage);
        }
        public void ReadReferenceLinesMeta_ValidFilePath_ReturnsElement()
        {
            // Setup
            string validFilePath = Path.Combine(testDataPath, "NBPW.shp");

            // Call
            IEnumerable <ReferenceLineMeta> referenceLineMetas = ReferenceLinesMetaReader.ReadReferenceLinesMetas(validFilePath);

            // Assert
            Assert.AreEqual(3, referenceLineMetas.Count());

            var expectedReferenceLineMeta1 = new ReferenceLineMeta
            {
                AssessmentSectionId = "1-1",
                MaximumAllowableFloodingProbability = 1000,
                SignalFloodingProbability           = 3000
            };

            expectedReferenceLineMeta1.ReferenceLine.SetGeometry(new[]
            {
                new Point2D(160679.9250, 475072.583),
                new Point2D(160892.0751, 474315.4917)
            });
            AssertReferenceLineMetas(expectedReferenceLineMeta1, referenceLineMetas.ElementAt(0));

            var expectedReferenceLineMeta2 = new ReferenceLineMeta
            {
                AssessmentSectionId = "2-2",
                MaximumAllowableFloodingProbability = 100,
                SignalFloodingProbability           = 300
            };

            expectedReferenceLineMeta2.ReferenceLine.SetGeometry(new[]
            {
                new Point2D(155556.9191, 464341.1281),
                new Point2D(155521.4761, 464360.7401)
            });
            AssertReferenceLineMetas(expectedReferenceLineMeta2, referenceLineMetas.ElementAt(1));

            var expectedReferenceLineMeta3 = new ReferenceLineMeta
            {
                AssessmentSectionId = "3-3",
                MaximumAllowableFloodingProbability = 100,
                SignalFloodingProbability           = 300
            };

            expectedReferenceLineMeta3.ReferenceLine.SetGeometry(new[]
            {
                new Point2D(147367.321899, 476902.9157103),
                new Point2D(147410.0515, 476938.9447)
            });
            AssertReferenceLineMetas(expectedReferenceLineMeta3, referenceLineMetas.ElementAt(2));
        }
        public void ReadReferenceLinesMetas_FilePathIsActuallyDirectoryPath_ThrowArgumentException()
        {
            // Setup
            string invalidFilePath = Path.Combine(testDataPath, Path.DirectorySeparatorChar.ToString());

            // Call
            TestDelegate call = () => ReferenceLinesMetaReader.ReadReferenceLinesMetas(invalidFilePath);

            // Assert
            string expectedMessage = $"Fout bij het lezen van bestand '{invalidFilePath}': bestandspad mag niet verwijzen naar een lege bestandsnaam.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(call, expectedMessage);
        }
        public void ReadReferenceLinesMeta_EmptyTrackId_ReturnsElement()
        {
            // Setup
            string validFilePath = Path.Combine(testDataPath, "NBPW_EmptyTrackId.shp");

            // Call
            IEnumerable <ReferenceLineMeta> referenceLineMetas = ReferenceLinesMetaReader.ReadReferenceLinesMetas(validFilePath);

            // Assert
            ReferenceLineMeta referenceLineMeta = referenceLineMetas.Single();

            Assert.IsEmpty(referenceLineMeta.AssessmentSectionId);
        }
        public void ReadReferenceLinesMetas_FileLacksAttributes_ThrowCriticalFileReadException(string shapeFileName, string missingAttributes)
        {
            // Setup
            string validFilePath = Path.Combine(testDataPath, shapeFileName);

            TestDelegate call = () => ReferenceLinesMetaReader.ReadReferenceLinesMetas(validFilePath);

            // Assert
            string message         = Assert.Throws <CriticalFileReadException>(call).Message;
            string expectedMessage = $"Het shapebestand '{validFilePath}' om trajecten te specificeren moet de attributen 'TRAJECT_ID', 'NORM_SW', en 'NORM_OG' bevatten: '{missingAttributes}' niet gevonden.";

            Assert.AreEqual(expectedMessage, message);
        }
        public void ReadReferenceLinesMeta_ShapefileHasMultiplePolylines_ReturnsEmptyReferenceLines(string shapeFileName)
        {
            // Setup
            string invalidFilePath = Path.Combine(testDataPath, shapeFileName);

            // Call
            IEnumerable <ReferenceLineMeta> referenceLineMetas = ReferenceLinesMetaReader.ReadReferenceLinesMetas(invalidFilePath);

            // Assert
            Assert.AreEqual(2, referenceLineMetas.Count());
            CollectionAssert.IsEmpty(referenceLineMetas.ElementAt(0).ReferenceLine.Points);
            CollectionAssert.IsEmpty(referenceLineMetas.ElementAt(1).ReferenceLine.Points);
        }
        public void ReadReferenceLinesMetas_ShapefileDoesNotHaveSinglePolyline_ThrowCriticalFileReadException(string shapeFileName)
        {
            // Setup
            string invalidFilePath = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, shapeFileName);

            TestDelegate call = () => ReferenceLinesMetaReader.ReadReferenceLinesMetas(invalidFilePath);

            // Assert .
            string expectedMessage = $"Fout bij het lezen van bestand '{invalidFilePath}': kon geen lijnen vinden in dit bestand.";
            string message         = Assert.Throws <CriticalFileReadException>(call).Message;

            Assert.AreEqual(expectedMessage, message);
        }
        public void ReadReferenceLinesMetas_ShapefileDoesntExist_ThrowCriticalFileReadException()
        {
            // Setup
            string invalidFilePath = Path.Combine(testDataPath, "I_do_not_exist.shp");

            // Call
            TestDelegate call = () => ReferenceLinesMetaReader.ReadReferenceLinesMetas(invalidFilePath);

            // Assert
            string expectedMessage = $"Fout bij het lezen van bestand '{invalidFilePath}': het bestand bestaat niet.";
            string message         = Assert.Throws <CriticalFileReadException>(call).Message;

            Assert.AreEqual(expectedMessage, message);
        }
        public void ReadReferenceLinesMeta_EmptyNormOgAndNormSw_ReturnsElement()
        {
            // Setup
            string validFilePath = Path.Combine(testDataPath, "NBPW_EmptyNormOGAndNormSW.shp");

            // Call
            IEnumerable <ReferenceLineMeta> referenceLineMetas = ReferenceLinesMetaReader.ReadReferenceLinesMetas(validFilePath);

            // Assert
            ReferenceLineMeta referenceLineMeta = referenceLineMetas.Single();

            Assert.AreEqual("46-1", referenceLineMeta.AssessmentSectionId);
            Assert.IsNull(referenceLineMeta.SignalFloodingProbability);
            Assert.AreEqual(0, referenceLineMeta.MaximumAllowableFloodingProbability);
        }
        public void ReadReferenceLinesMetas_FilePathHasInvalidPathCharacter_ThrowArgumentException()
        {
            // Setup
            char[] invalidPathChars = Path.GetInvalidPathChars();

            string validFilePath   = Path.Combine(testDataPath, "NBPW.shp");
            string invalidFilePath = validFilePath.Replace("P", invalidPathChars[1].ToString());

            // Call
            TestDelegate call = () => ReferenceLinesMetaReader.ReadReferenceLinesMetas(invalidFilePath);

            // Assert
            string expectedMessage = $"Fout bij het lezen van bestand '{invalidFilePath}': "
                                     + "er zitten ongeldige tekens in het bestandspad. Alle tekens in het bestandspad moeten geldig zijn.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(call, expectedMessage);
        }