Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/DikeProfilesImporterTest.cs =================================================================== diff -u -rfe90a6d174a01975381e6cda55ed1f7f4e831a51 -r31f4ca2b08257cf05459f63e0d715239e3d90c55 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/DikeProfilesImporterTest.cs (.../DikeProfilesImporterTest.cs) (revision fe90a6d174a01975381e6cda55ed1f7f4e831a51) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/DikeProfilesImporterTest.cs (.../DikeProfilesImporterTest.cs) (revision 31f4ca2b08257cf05459f63e0d715239e3d90c55) @@ -282,7 +282,8 @@ new ProgressNotification("Inlezen van profielgegevens.", 5, 5), new ProgressNotification(expectedAddDataToModelProgressText, 1, 1) }; - ValidateProgressMessages(expectedProgressMessages, progressChangeNotifications); + ProgressNotificationTestHelper.AssertProgressNotificationsAreEqual(expectedProgressMessages, + progressChangeNotifications); Assert.IsTrue(updateDataStrategy.Updated); Assert.AreEqual(5, updateDataStrategy.ReadDikeProfiles.Length); @@ -381,7 +382,9 @@ new ProgressNotification("Inlezen van profielgegevens.", 5, 5), new ProgressNotification(expectedAddDataToModelProgressText, 1, 1) }; - ValidateProgressMessages(expectedProgressMessages, progressChangeNotifications); + ProgressNotificationTestHelper.AssertProgressNotificationsAreEqual(expectedProgressMessages, + progressChangeNotifications); + Assert.IsTrue(updateDataStrategy.Updated); Assert.AreEqual(5, updateDataStrategy.ReadDikeProfiles.Length); } @@ -579,33 +582,5 @@ }); return referenceLine; } - - private static void ValidateProgressMessages(List expectedProgressMessages, - List progressChangeNotifications) - { - Assert.AreEqual(expectedProgressMessages.Count, progressChangeNotifications.Count); - for (var i = 0; i < expectedProgressMessages.Count; i++) - { - ProgressNotification notification = expectedProgressMessages[i]; - ProgressNotification actualNotification = progressChangeNotifications[i]; - Assert.AreEqual(notification.Text, actualNotification.Text); - Assert.AreEqual(notification.CurrentStep, actualNotification.CurrentStep); - Assert.AreEqual(notification.TotalSteps, actualNotification.TotalSteps); - } - } - - private class ProgressNotification - { - public ProgressNotification(string description, int currentStep, int totalSteps) - { - Text = description; - CurrentStep = currentStep; - TotalSteps = totalSteps; - } - - public string Text { get; } - public int CurrentStep { get; } - public int TotalSteps { get; } - } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/FailureMechanismSectionsImporterTest.cs =================================================================== diff -u -rd1bf253a0e3f11a168b4e185c4413c23995a1e8b -r31f4ca2b08257cf05459f63e0d715239e3d90c55 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/FailureMechanismSectionsImporterTest.cs (.../FailureMechanismSectionsImporterTest.cs) (revision d1bf253a0e3f11a168b4e185c4413c23995a1e8b) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/FailureMechanismSectionsImporterTest.cs (.../FailureMechanismSectionsImporterTest.cs) (revision 31f4ca2b08257cf05459f63e0d715239e3d90c55) @@ -34,6 +34,7 @@ using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.IO.FileImporters; using Ringtoets.Common.IO.ReferenceLines; +using Ringtoets.Common.IO.TestUtil; namespace Ringtoets.Common.IO.Test.FileImporters { @@ -198,15 +199,9 @@ new ProgressNotification("Valideren ingelezen vakindeling.", 2, 3), new ProgressNotification("Geïmporteerde data toevoegen aan het toetsspoor.", 3, 3) }; - Assert.AreEqual(expectedProgressMessages.Length, progressChangeNotifications.Count); - for (var i = 0; i < expectedProgressMessages.Length; i++) - { - ProgressNotification notification = expectedProgressMessages[i]; - ProgressNotification actualNotification = progressChangeNotifications[i]; - Assert.AreEqual(notification.Text, actualNotification.Text); - Assert.AreEqual(notification.CurrentStep, actualNotification.CurrentStep); - Assert.AreEqual(notification.TotalSteps, actualNotification.TotalSteps); - } + + ProgressNotificationTestHelper.AssertProgressNotificationsAreEqual(expectedProgressMessages, + progressChangeNotifications); } [Test] @@ -657,19 +652,5 @@ } } } - - private class ProgressNotification - { - public ProgressNotification(string description, int currentStep, int totalSteps) - { - Text = description; - CurrentStep = currentStep; - TotalSteps = totalSteps; - } - - public string Text { get; } - public int CurrentStep { get; } - public int TotalSteps { get; } - } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/ForeshoreProfilesImporterTest.cs =================================================================== diff -u -ra940166534b3dd6e778de2e7c8e7e5241f3d3381 -r31f4ca2b08257cf05459f63e0d715239e3d90c55 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/ForeshoreProfilesImporterTest.cs (.../ForeshoreProfilesImporterTest.cs) (revision a940166534b3dd6e778de2e7c8e7e5241f3d3381) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/ForeshoreProfilesImporterTest.cs (.../ForeshoreProfilesImporterTest.cs) (revision 31f4ca2b08257cf05459f63e0d715239e3d90c55) @@ -36,6 +36,7 @@ using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.IO.FileImporters; using Ringtoets.Common.IO.FileImporters.MessageProviders; +using Ringtoets.Common.IO.TestUtil; namespace Ringtoets.Common.IO.Test.FileImporters { @@ -322,7 +323,8 @@ new ProgressNotification("Inlezen van profielgegevens.", 5, 5), new ProgressNotification(expectedAddingDataToModelMessage, 1, 1) }; - ValidateProgressMessages(expectedProgressMessages, progressChangeNotifications); + ProgressNotificationTestHelper.AssertProgressNotificationsAreEqual(expectedProgressMessages, + progressChangeNotifications); } [Test] @@ -453,7 +455,8 @@ new ProgressNotification("Inlezen van profielgegevens.", 5, 5), new ProgressNotification(expectedAddingDataToModelMessage, 1, 1) }; - ValidateProgressMessages(expectedProgressMessages, progressChangeNotifications); + ProgressNotificationTestHelper.AssertProgressNotificationsAreEqual(expectedProgressMessages, + progressChangeNotifications); // 'observer' should not be notified } @@ -672,32 +675,5 @@ }); return referenceLine; } - - private static void ValidateProgressMessages(List expectedProgressMessages, List progressChangeNotifications) - { - Assert.AreEqual(expectedProgressMessages.Count, progressChangeNotifications.Count); - for (var i = 0; i < expectedProgressMessages.Count; i++) - { - ProgressNotification notification = expectedProgressMessages[i]; - ProgressNotification actualNotification = progressChangeNotifications[i]; - Assert.AreEqual(notification.Text, actualNotification.Text); - Assert.AreEqual(notification.CurrentStep, actualNotification.CurrentStep); - Assert.AreEqual(notification.TotalSteps, actualNotification.TotalSteps); - } - } - - private class ProgressNotification - { - public ProgressNotification(string description, int currentStep, int totalSteps) - { - Text = description; - CurrentStep = currentStep; - TotalSteps = totalSteps; - } - - public string Text { get; } - public int CurrentStep { get; } - public int TotalSteps { get; } - } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelImporterTest.cs =================================================================== diff -u -r09ab76fbe4f768414ad7dd356eb9b2ebd5b1781c -r31f4ca2b08257cf05459f63e0d715239e3d90c55 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelImporterTest.cs (.../StochasticSoilModelImporterTest.cs) (revision 09ab76fbe4f768414ad7dd356eb9b2ebd5b1781c) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilModelImporterTest.cs (.../StochasticSoilModelImporterTest.cs) (revision 31f4ca2b08257cf05459f63e0d715239e3d90c55) @@ -36,6 +36,7 @@ using Ringtoets.Common.IO.FileImporters.MessageProviders; using Ringtoets.Common.IO.SoilProfile; using Ringtoets.Common.IO.SoilProfile.Schema; +using Ringtoets.Common.IO.TestUtil; namespace Ringtoets.Common.IO.Test.SoilProfile { @@ -314,15 +315,8 @@ } expectedProgressMessages.Add(new ProgressNotification(expectedAddDataText, 1, 1)); - Assert.AreEqual(expectedProgressMessages.Count, progressChangeNotifications.Count); - for (var i = 0; i < expectedProgressMessages.Count; i++) - { - ProgressNotification notification = expectedProgressMessages[i]; - ProgressNotification actualNotification = progressChangeNotifications[i]; - Assert.AreEqual(notification.Text, actualNotification.Text); - Assert.AreEqual(notification.CurrentStep, actualNotification.CurrentStep); - Assert.AreEqual(notification.TotalSteps, actualNotification.TotalSteps); - } + ProgressNotificationTestHelper.AssertProgressNotificationsAreEqual(expectedProgressMessages, + progressChangeNotifications); } [Test] @@ -372,15 +366,8 @@ "Inlezen van de stochastische ondergrondmodellen.", i, totalNrOfStochasticSoilModelInDatabase)); } - Assert.AreEqual(expectedProgressMessages.Count, progressChangeNotifications.Count); - for (var i = 0; i < expectedProgressMessages.Count; i++) - { - ProgressNotification notification = expectedProgressMessages[i]; - ProgressNotification actualNotification = progressChangeNotifications[i]; - Assert.AreEqual(notification.Text, actualNotification.Text); - Assert.AreEqual(notification.CurrentStep, actualNotification.CurrentStep); - Assert.AreEqual(notification.TotalSteps, actualNotification.TotalSteps); - } + ProgressNotificationTestHelper.AssertProgressNotificationsAreEqual(expectedProgressMessages, + progressChangeNotifications); } [Test] @@ -853,20 +840,6 @@ invocation.ReturnValue = failureMechanismType == ((StochasticSoilModel) invocation.Arguments[0]).FailureMechanismType; } - private class ProgressNotification - { - public ProgressNotification(string description, int currentStep, int totalSteps) - { - Text = description; - CurrentStep = currentStep; - TotalSteps = totalSteps; - } - - public string Text { get; } - public int CurrentStep { get; } - public int TotalSteps { get; } - } - private class TestStochasticSoilModelCollection : ObservableUniqueItemCollectionWithSourcePath { public TestStochasticSoilModelCollection() Index: Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil.Test/ProgressNotificationTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil.Test/ProgressNotificationTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil.Test/ProgressNotificationTest.cs (revision 31f4ca2b08257cf05459f63e0d715239e3d90c55) @@ -0,0 +1,46 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using NUnit.Framework; + +namespace Ringtoets.Common.IO.TestUtil.Test +{ + [TestFixture] + public class ProgressNotificationTest + { + [Test] + public void Constructor_WithParameters_ExpectedProperties() + { + // Setup + const string description = "text"; + const int currentStep = 1; + const int totalSteps = 10; + + // Call + var notification = new ProgressNotification(description, currentStep, totalSteps); + + // Assert + Assert.AreEqual(description, notification.Description); + Assert.AreEqual(currentStep, notification.CurrentStep); + Assert.AreEqual(totalSteps, notification.TotalSteps); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil.Test/Ringtoets.Common.IO.TestUtil.Test.csproj =================================================================== diff -u -r7b7bd75dc1c1327386c9be96b5d480565bb8ecd6 -r31f4ca2b08257cf05459f63e0d715239e3d90c55 --- Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil.Test/Ringtoets.Common.IO.TestUtil.Test.csproj (.../Ringtoets.Common.IO.TestUtil.Test.csproj) (revision 7b7bd75dc1c1327386c9be96b5d480565bb8ecd6) +++ Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil.Test/Ringtoets.Common.IO.TestUtil.Test.csproj (.../Ringtoets.Common.IO.TestUtil.Test.csproj) (revision 31f4ca2b08257cf05459f63e0d715239e3d90c55) @@ -45,6 +45,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/ProgressNotification.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/ProgressNotification.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/ProgressNotification.cs (revision 31f4ca2b08257cf05459f63e0d715239e3d90c55) @@ -0,0 +1,57 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.Common.IO.TestUtil +{ + /// + /// Wrapper class for progress notifications which can be used for testing. + /// + public class ProgressNotification + { + /// + /// Creates a new instance of . + /// + /// The progress notification description. + /// The current step count. + /// The total number of steps. + public ProgressNotification(string description, int currentStep, int totalSteps) + { + Description = description; + CurrentStep = currentStep; + TotalSteps = totalSteps; + } + + /// + /// Gets the progress notification description. + /// + public string Description { get; } + + /// + /// Gets the current step count. + /// + public int CurrentStep { get; } + + /// + /// Gets the total number of steps. + /// + public int TotalSteps { get; } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/ProgressNotificationTestHelper.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/ProgressNotificationTestHelper.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/ProgressNotificationTestHelper.cs (revision 31f4ca2b08257cf05459f63e0d715239e3d90c55) @@ -0,0 +1,79 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework; + +namespace Ringtoets.Common.IO.TestUtil +{ + /// + /// A helper for asserting progress notifications. + /// + public static class ProgressNotificationTestHelper + { + /// + /// Asserts that is equal to . + /// + /// The value that is expected. + /// The actual value. + /// Thrown when the is + /// not equal to . + public static void AssertProgressNotificationsAreEqual(IEnumerable expected, + IEnumerable actual) + { + if (expected == null) + { + Assert.IsNull(expected); + return; + } + + ProgressNotification[] expectedArray = expected.ToArray(); + ProgressNotification[] actualArray = actual.ToArray(); + + Assert.AreEqual(expectedArray.Length, actualArray.Length); + for (var i = 0; i < expectedArray.Length; i++) + { + AssertProgressNotificationsAreEqual(expectedArray[i], actualArray[i]); + } + } + + /// + /// Asserts that is equal to . + /// + /// The value that is expected. + /// The actual value. + /// Thrown when the is + /// not equal to . + private static void AssertProgressNotificationsAreEqual(ProgressNotification expected, + ProgressNotification actual) + { + if (expected == null) + { + Assert.IsNull(expected); + return; + } + Assert.AreEqual(expected.Description, actual.Description); + Assert.AreEqual(expected.CurrentStep, actual.CurrentStep); + Assert.AreEqual(expected.TotalSteps, actual.TotalSteps); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/Ringtoets.Common.IO.TestUtil.csproj =================================================================== diff -u -r7b7bd75dc1c1327386c9be96b5d480565bb8ecd6 -r31f4ca2b08257cf05459f63e0d715239e3d90c55 --- Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/Ringtoets.Common.IO.TestUtil.csproj (.../Ringtoets.Common.IO.TestUtil.csproj) (revision 7b7bd75dc1c1327386c9be96b5d480565bb8ecd6) +++ Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/Ringtoets.Common.IO.TestUtil.csproj (.../Ringtoets.Common.IO.TestUtil.csproj) (revision 31f4ca2b08257cf05459f63e0d715239e3d90c55) @@ -52,6 +52,8 @@ + + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Importers/StochasticSoilModelImporterTest.cs =================================================================== diff -u -r78382ec129ddc7537096860680cef36f3796700d -r31f4ca2b08257cf05459f63e0d715239e3d90c55 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Importers/StochasticSoilModelImporterTest.cs (.../StochasticSoilModelImporterTest.cs) (revision 78382ec129ddc7537096860680cef36f3796700d) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Importers/StochasticSoilModelImporterTest.cs (.../StochasticSoilModelImporterTest.cs) (revision 31f4ca2b08257cf05459f63e0d715239e3d90c55) @@ -31,6 +31,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.Exceptions; using Ringtoets.Common.IO.FileImporters.MessageProviders; +using Ringtoets.Common.IO.TestUtil; using Ringtoets.MacroStabilityInwards.Data; using Ringtoets.MacroStabilityInwards.Data.SoilProfile; using Ringtoets.MacroStabilityInwards.IO.Importers; @@ -256,15 +257,9 @@ expectedProgressMessages.Add(new ProgressNotification("Valideren van ingelezen data.", i, expectedModels)); } expectedProgressMessages.Add(new ProgressNotification(expectedAddDataText, 1, 1)); - Assert.AreEqual(expectedProgressMessages.Count, progressChangeNotifications.Count); - for (var i = 0; i < expectedProgressMessages.Count; i++) - { - ProgressNotification notification = expectedProgressMessages[i]; - ProgressNotification actualNotification = progressChangeNotifications[i]; - Assert.AreEqual(notification.Text, actualNotification.Text); - Assert.AreEqual(notification.CurrentStep, actualNotification.CurrentStep); - Assert.AreEqual(notification.TotalSteps, actualNotification.TotalSteps); - } + + ProgressNotificationTestHelper.AssertProgressNotificationsAreEqual(expectedProgressMessages, + progressChangeNotifications); } [Test] @@ -1045,19 +1040,5 @@ { progress++; } - - private class ProgressNotification - { - public ProgressNotification(string description, int currentStep, int totalSteps) - { - Text = description; - CurrentStep = currentStep; - TotalSteps = totalSteps; - } - - public string Text { get; } - public int CurrentStep { get; } - public int TotalSteps { get; } - } } } \ No newline at end of file