Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/GrassCoverErosionOutwardsConfigurationExporterTest.cs =================================================================== diff -u -r5735c9b5c663a0bc7762d1b1eb1483e5c4cfe526 -r633aedbd4c882f2811c3e8e6653ef352301c40b5 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/GrassCoverErosionOutwardsConfigurationExporterTest.cs (.../GrassCoverErosionOutwardsConfigurationExporterTest.cs) (revision 5735c9b5c663a0bc7762d1b1eb1483e5c4cfe526) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/GrassCoverErosionOutwardsConfigurationExporterTest.cs (.../GrassCoverErosionOutwardsConfigurationExporterTest.cs) (revision 633aedbd4c882f2811c3e8e6653ef352301c40b5) @@ -19,15 +19,13 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using System.IO; -using System.Security.AccessControl; -using Core.Common.Base.IO; using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.IO.Exporters; using Ringtoets.GrassCoverErosionOutwards.Data; namespace Ringtoets.GrassCoverErosionOutwards.IO.Test @@ -42,34 +40,13 @@ var exporter = new GrassCoverErosionOutwardsConfigurationExporter(new CalculationGroup(), "test.xml"); // Assert - Assert.IsInstanceOf(exporter); + Assert.IsInstanceOf< + ConfigurationExporter< + GrassCoverErosionOutwardsConfigurationWriter, + GrassCoverErosionOutwardsWaveConditionsCalculation>>(exporter); } [Test] - public void Constructor_CalculationGroupNull_ThrowArgumentNullException() - { - // Call - TestDelegate test = () => new GrassCoverErosionOutwardsConfigurationExporter(null, "test.xml"); - - // Assert - var exception = Assert.Throws(test); - Assert.AreEqual("calculationGroup", exception.ParamName); - } - - [Test] - [TestCase("")] - [TestCase(" ")] - [TestCase("c:\\>")] - public void Constructor_FilePathInvalid_ThrowArgumentException(string filePath) - { - // Call - TestDelegate test = () => new GrassCoverErosionOutwardsConfigurationExporter(new CalculationGroup(), filePath); - - // Assert - Assert.Throws(test); - } - - [Test] public void Export_ValidData_ReturnTrueAndWritesFile() { // Setup @@ -143,38 +120,5 @@ File.Delete(filePath); } } - - [Test] - public void Export_InvalidDirectoryRights_LogErrorAndReturnFalse() - { - // Setup - var calculationGroup = new CalculationGroup - { - Children = - { - new GrassCoverErosionOutwardsWaveConditionsCalculation() - } - }; - - string directoryPath = TestHelper.GetScratchPadPath(nameof(Export_InvalidDirectoryRights_LogErrorAndReturnFalse)); - using (var disposeHelper = new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(Export_InvalidDirectoryRights_LogErrorAndReturnFalse))) - { - string filePath = Path.Combine(directoryPath, "test.xml"); - - var exporter = new GrassCoverErosionOutwardsConfigurationExporter(calculationGroup, filePath); - - disposeHelper.LockDirectory(FileSystemRights.Write); - - // Call - var isExported = true; - Action call = () => isExported = exporter.Export(); - - // Assert - string expectedMessage = $"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'. " - + "Er is geen configuratie geƫxporteerd."; - TestHelper.AssertLogMessageIsGenerated(call, expectedMessage); - Assert.IsFalse(isExported); - } - } } } \ No newline at end of file