public void Import_CancelOfImportWhenAddingDataToModel_ImportCompletedSuccessfullyNonetheless()
        {
            // Setup
            string validFilePath = Path.Combine(testDataPath, nameof(HeightStructuresImporter),
                                                "MissingParameters", "Kunstwerken.shp");
            var importTarget = new StructureCollection <HeightStructure>();

            const string progressText    = "ProgressText";
            var          messageProvider = mocks.StrictMock <IImporterMessageProvider>();

            messageProvider.Expect(mp => mp.GetAddDataToModelProgressText()).Return(progressText);

            var strategy = mocks.StrictMock <IStructureUpdateStrategy <HeightStructure> >();

            strategy.Expect(s => s.UpdateStructuresWithImportedData(Arg <IEnumerable <HeightStructure> > .Is.NotNull,
                                                                    Arg.Is(validFilePath)))
            .Return(Enumerable.Empty <IObservable>());
            mocks.ReplayAll();

            ReferenceLine referenceLine = CreateReferenceLine();
            var           importer      = new HeightStructuresImporter(importTarget, referenceLine, validFilePath,
                                                                       messageProvider, strategy);

            importer.SetProgressChanged((description, step, steps) =>
            {
                if (description.Contains(progressText))
                {
                    importer.Cancel();
                }
            });

            var importResult = false;

            // Call
            Action call = () => importResult = importer.Import();

            // Assert
            Tuple <string, LogLevelConstant> expectedLogMessage = Tuple.Create(
                "Huidige actie was niet meer te annuleren en is daarom voortgezet.", LogLevelConstant.Warn);

            TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedLogMessage);
            Assert.IsTrue(importResult);
        }
        public void Import_CancelOfImportWhenReadingStructureData_CancelsImportAndLogs()
        {
            // Setup
            const string cancelledLogMessage = "Operation Cancelled";
            var          messageProvider     = mocks.StrictMock <IImporterMessageProvider>();

            messageProvider.Expect(mp => mp.GetCancelledLogMessageText("Kunstwerken")).Return(cancelledLogMessage);

            var strategy = mocks.StrictMock <IStructureUpdateStrategy <HeightStructure> >();

            mocks.ReplayAll();

            string validFilePath = Path.Combine(commonIoTestDataPath, "CorrectFiles", "Kunstwerken.shp");

            var           importTarget  = new StructureCollection <HeightStructure>();
            ReferenceLine referenceLine = CreateReferenceLine();

            var importer = new HeightStructuresImporter(importTarget, referenceLine, validFilePath,
                                                        messageProvider, strategy);

            importer.SetProgressChanged(delegate(string description, int step, int steps)
            {
                if (description.Contains("Inlezen van kunstwerkgegevens uit een kommagescheiden bestand."))
                {
                    importer.Cancel();
                }
            });

            var importResult = true;

            // Call
            Action call = () => importResult = importer.Import();

            // Assert
            Tuple <string, LogLevelConstant> expectedLogMessage = Tuple.Create(cancelledLogMessage, LogLevelConstant.Info);

            TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedLogMessage);
            Assert.IsFalse(importResult);
        }