Пример #1
0
        public void ExportLocationCalculationsForTargetProbabilities_ValidData_ReturnsTrueAndWritesCorrectData(HydraulicBoundaryLocationCalculationsType calculationsType,
                                                                                                               string expectedExportFileName)
        {
            // Setup
            const double targetProbability = 0.05;

            string directoryPath = TestHelper.GetScratchPadPath(nameof(ExportLocationCalculationsForTargetProbabilities_ValidData_ReturnsTrueAndWritesCorrectData));

            Directory.CreateDirectory(directoryPath);

            string shapeFileName = GetExpectedShapeFileName(calculationsType, targetProbability);

            // Precondition
            FileTestHelper.AssertEssentialShapefilesExist(directoryPath, $"{shapeFileName}.shp", false);

            try
            {
                // Call
                bool isExported = HydraulicBoundaryLocationCalculationsExportHelper.ExportLocationCalculationsForTargetProbabilities(
                    new[]
                {
                    new Tuple <IEnumerable <HydraulicBoundaryLocationCalculation>, double>(new[]
                    {
                        new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2))
                    }, targetProbability)
                }, calculationsType, directoryPath);

                // Assert
                Assert.IsTrue(isExported);

                FileTestHelper.AssertEssentialShapefilesExist(directoryPath, shapeFileName, true);
                FileTestHelper.AssertEssentialShapefileMd5Hashes(
                    directoryPath, shapeFileName,
                    Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Riskeer.Integration.IO),
                                 nameof(HydraulicBoundaryLocationCalculationsExportHelper)),
                    expectedExportFileName, 28, 8, 628);
            }
            finally
            {
                DirectoryHelper.TryDelete(directoryPath);
            }
        }
        public void Export_ValidData_ReturnsTrueAndWritesCorrectData(HydraulicBoundaryLocationCalculationsType calculationsType,
                                                                     string expectedExportFileName)
        {
            // Setup
            const string fileName = "test";

            string directoryPath = TestHelper.GetScratchPadPath(nameof(Export_ValidData_ReturnsTrueAndWritesCorrectData));

            Directory.CreateDirectory(directoryPath);
            string filePath = Path.Combine(directoryPath, $"{fileName}.shp");

            var exporter = new HydraulicBoundaryLocationCalculationsForTargetProbabilityExporter(new[]
            {
                new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2))
            }, filePath, calculationsType);

            // Precondition
            FileTestHelper.AssertEssentialShapefilesExist(directoryPath, fileName, false);

            try
            {
                // Call
                bool isExported = exporter.Export();

                // Assert
                FileTestHelper.AssertEssentialShapefilesExist(directoryPath, fileName, true);
                FileTestHelper.AssertEssentialShapefileMd5Hashes(
                    directoryPath, fileName,
                    Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Riskeer.Integration.IO),
                                 nameof(HydraulicBoundaryLocationCalculationsForTargetProbabilityExporter)),
                    expectedExportFileName, 28, 8, 628);
                Assert.IsTrue(isExported);
            }
            finally
            {
                DirectoryHelper.TryDelete(directoryPath);
            }
        }
Пример #3
0
        public void WriteReferenceLine_ValidData_WritesShapeFile()
        {
            // Setup
            var referenceLine = new ReferenceLine();

            referenceLine.SetGeometry(new[]
            {
                new Point2D(1.1, 2.2),
                new Point2D(11.11, 22.22)
            });

            string directoryPath = TestHelper.GetScratchPadPath(nameof(WriteReferenceLine_ValidData_WritesShapeFile));

            using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(WriteReferenceLine_ValidData_WritesShapeFile)))
            {
                Directory.CreateDirectory(directoryPath);
                string       filePath = Path.Combine(directoryPath, "test.shp");
                const string baseName = "test";

                var writer = new ReferenceLineWriter();

                // Precondition
                FileTestHelper.AssertEssentialShapefilesExist(directoryPath, baseName, false);

                // Call
                writer.WriteReferenceLine(referenceLine, "anId", filePath);

                // Assert
                FileTestHelper.AssertEssentialShapefilesExist(directoryPath, baseName, true);
                FileTestHelper.AssertEssentialShapefileMd5Hashes(directoryPath,
                                                                 baseName,
                                                                 TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO),
                                                                 "LineShapefileMd5",
                                                                 88,
                                                                 8,
                                                                 289);
            }
        }
        public void WriteHydraulicBoundaryLocationCalculations_ValidData_WritesShapeFile(HydraulicBoundaryLocationCalculationsType calculationsType,
                                                                                         string expectedExportFileName)
        {
            // Setup
            const string fileName      = "test";
            string       directoryPath = TestHelper.GetScratchPadPath(nameof(WriteHydraulicBoundaryLocationCalculations_ValidData_WritesShapeFile));
            string       filePath      = Path.Combine(directoryPath, $"{fileName}.shp");

            // Precondition
            FileTestHelper.AssertEssentialShapefilesExist(directoryPath, fileName, false);

            var calculation = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation("location 1"))
            {
                Output = new TestHydraulicBoundaryLocationCalculationOutput(0.1)
            };

            try
            {
                // Call
                HydraulicBoundaryLocationCalculationsForTargetProbabilityWriter.WriteHydraulicBoundaryLocationCalculations(new[]
                {
                    calculation
                }, filePath, calculationsType);

                // Assert
                FileTestHelper.AssertEssentialShapefilesExist(directoryPath, fileName, true);
                FileTestHelper.AssertEssentialShapefileMd5Hashes(
                    directoryPath, fileName,
                    Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Riskeer.Integration.IO),
                                 nameof(HydraulicBoundaryLocationCalculationsForTargetProbabilityWriter)),
                    expectedExportFileName, 28, 8, 628);
            }
            finally
            {
                DirectoryHelper.TryDelete(directoryPath);
            }
        }