Esempio n. 1
0
        public void NotifyProgress_DelegateSet_CallProgressChanged()
        {
            // Setup
            const string expectedDescription   = "B";
            const int    expectedStep          = 1;
            const int    expectedNumberOfSteps = 3;

            var importTarget             = new object();
            var simpleImporter           = new SimpleFileImporter <object>(importTarget);
            var progressChangedCallCount = 0;

            simpleImporter.SetProgressChanged((description, step, steps) =>
            {
                Assert.AreEqual(expectedDescription, description);
                Assert.AreEqual(expectedStep, step);
                Assert.AreEqual(expectedNumberOfSteps, steps);
                progressChangedCallCount++;
            });

            // Call
            simpleImporter.TestNotifyProgress(expectedDescription, expectedStep, expectedNumberOfSteps);

            // Assert
            Assert.AreEqual(1, progressChangedCallCount);
        }
Esempio n. 2
0
        public void NotifyProgress_NoDelegateSet_DoNothing()
        {
            // Setup
            var importTarget   = new object();
            var simpleImporter = new SimpleFileImporter <object>(importTarget);

            simpleImporter.SetProgressChanged(null);

            // Call
            TestDelegate call = () => simpleImporter.TestNotifyProgress("A", 1, 2);

            // Assert
            Assert.DoesNotThrow(call);
        }
Esempio n. 3
0
        public void Import_CancelGivesUnsuccessfulImport_CallsLogImportCanceledMessage()
        {
            //  Setup
            var importTarget   = new object();
            var simpleImporter = new SimpleFileImporter <object>(importTarget)
            {
                ImportSuccessful = false
            };

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

            // Call
            simpleImporter.Import();

            // Assert
            Assert.IsTrue(simpleImporter.LogCanceledMessageCalled);
        }
Esempio n. 4
0
        public void Import_CancelGivesSuccessfulImport_LogsMessage()
        {
            //  Setup
            var importTarget   = new object();
            var simpleImporter = new SimpleFileImporter <object>(importTarget)
            {
                ImportSuccessful = true
            };

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

            // Call
            Action call = () => simpleImporter.Import();

            // Assert
            TestHelper.AssertLogMessageWithLevelIsGenerated(call, new Tuple <string, LogLevelConstant>(
                                                                "Huidige actie was niet meer te annuleren en is daarom voortgezet.",
                                                                LogLevelConstant.Warn));
        }