Example #1
0
        public void Import_ReuseOfCanceledImportToValidTargetWithValidFile_ReturnsTrue()
        {
            // Setup
            var messageProvider = mocks.Stub <IImporterMessageProvider>();
            var updateStrategy  = mocks.Stub <IStructureUpdateStrategy <TestStructure> >();

            mocks.ReplayAll();

            string filePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO,
                                                         Path.Combine("Structures", "CorrectFiles", "Kunstwerken.shp"));

            ReferenceLine referenceLine          = CreateReferenceLine();
            var           importTarget           = new StructureCollection <TestStructure>();
            var           testStructuresImporter = new TestStructuresImporter(importTarget,
                                                                              referenceLine,
                                                                              filePath,
                                                                              updateStrategy,
                                                                              messageProvider);

            testStructuresImporter.SetProgressChanged((description, step, steps) => testStructuresImporter.Cancel());

            bool importResult = testStructuresImporter.Import();

            // Precondition
            Assert.IsFalse(importResult);
            testStructuresImporter.SetProgressChanged(null);

            // Call
            importResult = testStructuresImporter.Import();

            // Assert
            Assert.IsTrue(importResult);
        }
Example #2
0
        public void Import_CancelOfImportWhenCreatingStructures_ContinueImportAndLogWarning()
        {
            // Setup
            const string addDataToModelProgressText = "addDataToModelProgressText";
            var          messageProvider            = mocks.StrictMock <IImporterMessageProvider>();

            messageProvider.Expect(mp => mp.GetAddDataToModelProgressText()).Return(addDataToModelProgressText);
            var updateStrategy = mocks.Stub <IStructureUpdateStrategy <TestStructure> >();

            mocks.ReplayAll();

            string filePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO,
                                                         Path.Combine("Structures", "CorrectFiles", "Kunstwerken.shp"));

            ReferenceLine referenceLine          = CreateReferenceLine();
            var           importTarget           = new StructureCollection <TestStructure>();
            var           testStructuresImporter = new TestStructuresImporter(importTarget,
                                                                              referenceLine,
                                                                              filePath,
                                                                              updateStrategy,
                                                                              messageProvider);

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

            var importResult = true;

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

            // Assert
            const string expectedMessage = "Huidige actie was niet meer te annuleren en is daarom voortgezet.";

            TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Warn), 2);
            Assert.IsTrue(importResult);
        }
Example #3
0
        public void Import_CancelOfImportWhenReadingStructureData_FalseAndLogInfo()
        {
            // Setup
            const string messageText     = "importeren is afgebroken";
            var          messageProvider = mocks.StrictMock <IImporterMessageProvider>();

            messageProvider.Expect(mp => mp.GetCancelledLogMessageText("Kunstwerken")).Return(messageText);
            var updateStrategy = mocks.Stub <IStructureUpdateStrategy <TestStructure> >();

            mocks.ReplayAll();

            string filePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO,
                                                         Path.Combine("Structures", "CorrectFiles", "Kunstwerken.shp"));

            ReferenceLine referenceLine          = CreateReferenceLine();
            var           importTarget           = new StructureCollection <TestStructure>();
            var           testStructuresImporter = new TestStructuresImporter(importTarget,
                                                                              referenceLine,
                                                                              filePath,
                                                                              updateStrategy,
                                                                              messageProvider);

            testStructuresImporter.SetProgressChanged((description, step, steps) =>
            {
                if (description.Contains("Inlezen van kunstwerkgegevens uit een kommagescheiden bestand."))
                {
                    testStructuresImporter.Cancel();
                }
            });

            var importResult = true;

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

            // Assert
            TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(messageText, LogLevelConstant.Info), 1);
            Assert.IsFalse(importResult);
        }