public void Constructor_ExpectedValues()
        {
            // Setup
            var mapDataCollection = new MapDataCollection("test");

            // Call
            var importer = new FeatureBasedMapDataImporter(mapDataCollection, "");

            // Assert
            Assert.IsInstanceOf <FileImporterBase <MapDataCollection> >(importer);
        }
        public void Import_ValidShapeFile_ImportDataOnMapDataCollection(string fileName)
        {
            // Setup
            string path = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, fileName);
            var    mapDataCollection = new MapDataCollection("test");
            var    importer          = new FeatureBasedMapDataImporter(mapDataCollection, path);

            // Precondition
            CollectionAssert.IsEmpty(mapDataCollection.Collection);

            // Call
            bool importSuccessful = importer.Import();

            // Assert
            Assert.IsTrue(importSuccessful);
            Assert.AreEqual(1, mapDataCollection.Collection.Count());
        }
        public void Import_ShapeFileEmptyFile_CancelImportWithErrorMessage()
        {
            // Setup
            string path = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, "EmptyFile.shp");
            var    mapDataCollection = new MapDataCollection("test");
            var    importer          = new FeatureBasedMapDataImporter(mapDataCollection, path);

            // Call
            var    importSuccessful = true;
            Action call             = () => importSuccessful = importer.Import();

            // Assert
            string expectedMessage = $@"Fout bij het lezen van bestand '{path}': kon geen geometrieën vinden in dit bestand." +
                                     $"{Environment.NewLine}Er is geen kaartlaag geïmporteerd.";

            TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
            Assert.IsFalse(importSuccessful);
        }
        public void Import_ShapefileDoesNotExist_CancelImportWithErrorMessage()
        {
            // Setup
            string path = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, "I_dont_exist.shp");
            var    mapDataCollection = new MapDataCollection("test");
            var    importer          = new FeatureBasedMapDataImporter(mapDataCollection, path);

            // Call
            var    importSuccessful = true;
            Action call             = () => importSuccessful = importer.Import();

            // Assert
            string expectedMessage = $@"Fout bij het lezen van bestand '{path}': het bestand of andere benodigde bestanden zijn niet gevonden." +
                                     $"{Environment.NewLine}Er is geen kaartlaag geïmporteerd.";

            TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
            Assert.IsFalse(importSuccessful);
        }
        public void Import_ShapeFileCorrupt_CancelImportWithErrorMessage()
        {
            // Setup
            string path = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, "CorruptFile.shp");
            var    mapDataCollection = new MapDataCollection("test");
            var    importer          = new FeatureBasedMapDataImporter(mapDataCollection, path);

            // Call
            var    importSuccessful = true;
            Action call             = () => importSuccessful = importer.Import();

            // Assert
            string expectedMessage = $@"Fout bij het lezen van bestand '{path}': het bestand kon niet worden geopend. " +
                                     "Mogelijk is het bestand corrupt of in gebruik door een andere applicatie." +
                                     $"{Environment.NewLine}Er is geen kaartlaag geïmporteerd.";

            TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
            Assert.IsFalse(importSuccessful);
        }
        public void DoPostImportUpdates_ImportSuccessful_NotifiesMapDataCollection()
        {
            // Setup
            var mocks    = new MockRepository();
            var observer = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());
            mocks.ReplayAll();

            string path = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, "Single_Point_with_ID.shp");
            var    mapDataCollection = new MapDataCollection("test");

            mapDataCollection.Attach(observer);
            var importer = new FeatureBasedMapDataImporter(mapDataCollection, path);

            // Precondition
            Assert.IsTrue(importer.Import());

            // Call
            importer.DoPostImport();

            // Assert
            mocks.VerifyAll();
        }