Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/CalculationConfigurationImporterTest.cs =================================================================== diff -u -r7594d7f46113b5c5f4f41bfbd0183a3789f648b9 -rc3b5df96e7f9f0563b924ebe53526963a4e7cc76 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/CalculationConfigurationImporterTest.cs (.../CalculationConfigurationImporterTest.cs) (revision 7594d7f46113b5c5f4f41bfbd0183a3789f648b9) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/CalculationConfigurationImporterTest.cs (.../CalculationConfigurationImporterTest.cs) (revision c3b5df96e7f9f0563b924ebe53526963a4e7cc76) @@ -38,7 +38,7 @@ [TestFixture] public class CalculationConfigurationImporterTest { - private readonly string readerPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "ConfigurationReader"); + private readonly string readerPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "CalculationConfigurationReader"); [Test] public void Constructor_ExpectedValues() @@ -144,6 +144,46 @@ Assert.IsFalse(importSuccessful); } + [Test] + public void GivenImport_WhenImporting_ThenExpectedProgressMessagesGenerated() + { + // Given + string filePath = Path.Combine(readerPath, "validConfiguration.xml"); + var importer = new TestCalculationConfigurationImporter(filePath, + new CalculationGroup()); + + var expectedProgressMessages = new[] + { + new ExpectedProgressNotification + { + Text = "Inlezen berekeningenconfiguratie.", CurrentStep = 1, TotalNumberOfSteps = 3 + }, + new ExpectedProgressNotification + { + Text = "Valideren berekeningenconfiguratie.", CurrentStep = 2, TotalNumberOfSteps = 3 + }, + new ExpectedProgressNotification + { + Text = "Geïmporteerde data toevoegen aan het toetsspoor.", CurrentStep = 3, TotalNumberOfSteps = 3 + } + }; + + var progressChangedCallCount = 0; + importer.SetProgressChanged((description, step, steps) => + { + Assert.AreEqual(expectedProgressMessages[progressChangedCallCount].Text, description); + Assert.AreEqual(expectedProgressMessages[progressChangedCallCount].CurrentStep, step); + Assert.AreEqual(expectedProgressMessages[progressChangedCallCount].TotalNumberOfSteps, steps); + progressChangedCallCount++; + }); + + // When + importer.Import(); + + // Then + Assert.AreEqual(expectedProgressMessages.Length, progressChangedCallCount); + } + private class TestCalculationConfigurationImporter : CalculationConfigurationImporter { public TestCalculationConfigurationImporter(string filePath, CalculationGroup importTarget) @@ -168,7 +208,7 @@ private static readonly string mainSchemaDefinition = File.ReadAllText(Path.Combine(TestHelper.GetTestDataPath( TestDataPath.Ringtoets.Common.IO, - "ConfigurationReader"), + "CalculationConfigurationReader"), "validConfigurationSchema.xsd")); public TestCalculationConfigurationReader(string xmlFilePath) @@ -194,5 +234,12 @@ { public string Name { get; set; } } + + private class ExpectedProgressNotification + { + public string Text { get; set; } + public int CurrentStep { get; set; } + public int TotalNumberOfSteps { get; set; } + } } } \ No newline at end of file