Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/CalculationConfigurationWriterTest.cs =================================================================== diff -u -r2923096aeb41e1fb5d4ba0ad43ccb9f95ca7407a -r020439f88aaed9dd51967acbc8518f37c95791d1 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/CalculationConfigurationWriterTest.cs (.../CalculationConfigurationWriterTest.cs) (revision 2923096aeb41e1fb5d4ba0ad43ccb9f95ca7407a) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Writers/CalculationConfigurationWriterTest.cs (.../CalculationConfigurationWriterTest.cs) (revision 020439f88aaed9dd51967acbc8518f37c95791d1) @@ -41,21 +41,21 @@ public class CalculationConfigurationWriterTest { [Test] - public void Write_CalculationGroupNull_ThrowArgumentNullException() + public void Write_ConfigurationNull_ThrowArgumentNullException() { // Call TestDelegate test = () => new SimpleCalculationConfigurationWriter().Write(null, string.Empty); // Assert var exception = Assert.Throws(test); - Assert.AreEqual("rootCalculationGroup", exception.ParamName); + Assert.AreEqual("configuration", exception.ParamName); } [Test] public void Write_FilePathNull_ThrowArgumentNullException() { // Call - TestDelegate test = () => new SimpleCalculationConfigurationWriter().Write(new CalculationGroup(), null); + TestDelegate test = () => new SimpleCalculationConfigurationWriter().Write(Enumerable.Empty(), null); // Assert var exception = Assert.Throws(test); @@ -69,7 +69,7 @@ public void Write_FilePathInvalid_ThrowCriticalFileWriteException(string filePath) { // Call - TestDelegate call = () => new SimpleCalculationConfigurationWriter().Write(new CalculationGroup(), filePath); + TestDelegate call = () => new SimpleCalculationConfigurationWriter().Write(Enumerable.Empty(), filePath); // Assert var exception = Assert.Throws(call); @@ -84,7 +84,7 @@ var filePath = new string('a', 249); // Call - TestDelegate call = () => new SimpleCalculationConfigurationWriter().Write(new CalculationGroup(), filePath); + TestDelegate call = () => new SimpleCalculationConfigurationWriter().Write(Enumerable.Empty(), filePath); // Assert var exception = Assert.Throws(call); @@ -103,7 +103,7 @@ disposeHelper.LockDirectory(FileSystemRights.Write); // Call - TestDelegate call = () => new SimpleCalculationConfigurationWriter().Write(new CalculationGroup(), filePath); + TestDelegate call = () => new SimpleCalculationConfigurationWriter().Write(Enumerable.Empty(), filePath); // Assert var exception = Assert.Throws(call); @@ -123,7 +123,7 @@ fileDisposeHelper.LockFiles(); // Call - TestDelegate call = () => new SimpleCalculationConfigurationWriter().Write(new CalculationGroup(), path); + TestDelegate call = () => new SimpleCalculationConfigurationWriter().Write(Enumerable.Empty(), path); // Assert var exception = Assert.Throws(call); @@ -137,9 +137,6 @@ { // Setup string filePath = TestHelper.GetScratchPadPath("test_distributions_write.xml"); - string expectedXmlFilePath = TestHelper.GetTestDataPath( - TestDataPath.Ringtoets.Common.IO, - Path.Combine(nameof(CalculationConfigurationWriter), "distributions.xml")); try { @@ -325,7 +322,7 @@ [Test] [TestCaseSource(nameof(CalculationConfigurations))] - public void Write_DifferentCalculationAndCalculationGroupConfigurations_ValidFile(CalculationGroup rootGroup, string expectedFileContentsFileName) + public void Write_DifferentCalculationAndCalculationGroupConfigurations_ValidFile(IEnumerable configuration, string expectedFileContentsFileName) { // Setup string filePath = TestHelper.GetScratchPadPath("test.xml"); @@ -336,7 +333,7 @@ try { // Call - new SimpleCalculationConfigurationWriter().Write(rootGroup, filePath); + new SimpleCalculationConfigurationWriter().Write(configuration, filePath); // Assert Assert.IsTrue(File.Exists(filePath)); @@ -388,31 +385,35 @@ }; yield return new TestCaseData( - CreateRootGroupWithChildren(calculationGroup1), + new [] + { + calculationGroup1 + }, "singleGroup.xml") .SetName("Single group"); yield return new TestCaseData( - CreateRootGroupWithChildren(calculation1), + new[] + { + calculation1 + }, "singleCalculation.xml") .SetName("Single calculation"); yield return new TestCaseData( - CreateRootGroupWithChildren(calculationGroup1, calculation1), + new ICalculationBase[] + { + calculationGroup1, + calculation1 + }, "calculationGroupAndCalculation.xml") .SetName("Calculation group and calculation"); yield return new TestCaseData( - CreateRootGroupWithChildren(calculation1, calculationGroup2), + new ICalculationBase[] + { + calculation1, + calculationGroup2 + }, "calculationAndGroupWithNesting.xml") .SetName("Calculation and group with nesting"); } - - private static CalculationGroup CreateRootGroupWithChildren(params ICalculationBase[] children) - { - var group = new CalculationGroup("root", false); - foreach (ICalculationBase child in children) - { - group.Children.Add(child); - } - return group; - } } } \ No newline at end of file