public void CanProperlyCreateCommandLineOptionsForOgr2OgrUsingGeoJSON()
        {
            // Arrange
            // -------

            var          gdalDataDirectoryInfo = new DirectoryInfo(@"C:\Program Files\GDAL\gdal-data");
            const string sourceLayerName       = "MySourceLayerName";
            var          inputGdbFile          = new FileInfo(@"C:\temp\MyZippedGdbFile.gdb.zip");

            // Act
            // ---
            var actualCommandLineArguments = Ogr2OgrCommandLineRunner.BuildCommandLineArgumentsForFileGdbToGeoJson(
                inputGdbFile,
                gdalDataDirectoryInfo,
                sourceLayerName, CoordinateSystemId, true);

            // Assert
            // ------

            // Expecting a command line something like this:
            //"C:\Program Files\GDAL\ogr2ogr.exe" --config GDAL_DATA "C:\\Program Files\\GDAL\\gdal-data" -t_srs EPSG:4326 -explodecollections -f GeoJSON /dev/stdout "C:\\svn\\sitkatech\\trunk\\Corral\\Source\\ProjectFirma.Web\\Models\\GdalOgr\\SampleFileGeodatabase.gdb.zip"

            var expectedCommandLineArguments = new[] { "--config", "GDAL_DATA", gdalDataDirectoryInfo.FullName, "-t_srs", Ogr2OgrCommandLineRunner.GetMapProjection(CoordinateSystemId), "-explodecollections", "-f", "GeoJSON", "/dev/stdout", inputGdbFile.FullName, string.Format("\"{0}\"", sourceLayerName) };

            Assert.That(actualCommandLineArguments, Is.EquivalentTo(expectedCommandLineArguments), "Should produce expected arguments");

            var expectedCommandLineArgumentsEncodedString = string.Join(" ", expectedCommandLineArguments.Select(ProcessUtility.EncodeArgumentForCommandLine).ToList());
            var actualCommandLineArgumentsEncodedString   = string.Join(" ", actualCommandLineArguments.Select(ProcessUtility.EncodeArgumentForCommandLine).ToList());

            Assert.That(actualCommandLineArgumentsEncodedString, Is.EqualTo(expectedCommandLineArgumentsEncodedString), "Should produce the expected command line argument string in the correct order");
        }
        public void CanProperlyCreateCommandLineOptionsForArcGisQueryToMsSQL()
        {
            // Arrange
            // -------

            var          gdalDataDirectoryInfo = new DirectoryInfo(@"C:\Program Files\GDAL\gdal-data");
            const string destinationTableName  = "MyTableWithGeometry";
            const string arcGisQuery           = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Hydrography/GeospatialArea173811/FeatureServer/0/query?where=objectid+%3D+objectid&outfields=*&f=json";
            // Act
            // ---
            const string sourceColumnName           = "areasqkm";
            const string destinationColumnName      = "SquareKm";
            var          actualCommandLineArguments = Ogr2OgrCommandLineRunner.BuildCommandLineArgumentsForArgGisQueryToMsSql(arcGisQuery, gdalDataDirectoryInfo, TempDbSqlDatabase.DatabaseConnectionStringToTempDb, destinationTableName, sourceColumnName, destinationColumnName, CoordinateSystemId);

            // Assert
            // ------

            // Expecting a command line something like this:
            //"C:\Program Files\GDAL\ogr2ogr.exe" -append -sql "select areasqkm as SquareKm from OGRGeoJSON --config GDAL_DATA "C:\\Program Files\\GDAL\\gdal-data" -f MSSQLSpatial dbconnectionstring test.json "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Hydrography/GeospatialArea173811/FeatureServer/0/query?where=objectid+%3D+objectid&outfields=*&f=json" -nln SomeTableName"

            var expectedCommandLineArguments = new[]
            {
                "-append", "-sql", string.Format("SELECT {0} AS {1} FROM {2}", sourceColumnName, destinationColumnName, Ogr2OgrCommandLineRunner.OgrGeoJsonTableName), "--config", "GDAL_DATA", gdalDataDirectoryInfo.FullName, "-t_srs", Ogr2OgrCommandLineRunner.GetMapProjection(CoordinateSystemId),
                "-f", "MSSQLSpatial", TempDbSqlDatabase.DatabaseConnectionStringToTempDb, string.Format("\"{0}\"", arcGisQuery), "-nln", destinationTableName
            };

            Assert.That(actualCommandLineArguments, Is.EquivalentTo(expectedCommandLineArguments), "Should produce expected arguments");

            var expectedCommandLineArgumentsEncodedString = string.Join(" ", expectedCommandLineArguments.Select(ProcessUtility.EncodeArgumentForCommandLine).ToList());
            var actualCommandLineArgumentsEncodedString   = string.Join(" ", actualCommandLineArguments.Select(ProcessUtility.EncodeArgumentForCommandLine).ToList());

            Assert.That(actualCommandLineArgumentsEncodedString, Is.EqualTo(expectedCommandLineArgumentsEncodedString), "Should produce the expected command line argument string in the correct order");
        }