Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -r9f5fa34afb489eb0d46dab724e9d8121a31a04bb -rc0c23a5508146aad6005fc0eb3b78bab7a63dc63 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 9f5fa34afb489eb0d46dab724e9d8121a31a04bb) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision c0c23a5508146aad6005fc0eb3b78bab7a63dc63) @@ -219,7 +219,7 @@ var calculations = context.WrappedData.GetCalculations().Cast(); return new GrassCoverErosionOutwardsWaveConditionsExporter(calculations, filePath); }, - IsEnabled = context => context.WrappedData.GetCalculations().Cast().Any(c => c.HasOutput), + IsEnabled = context => context.WrappedData.GetCalculations().Any(c => c.HasOutput), FileFilter = RingtoetsCommonFormsResources.DataTypeDisplayName_csv_file_filter }; Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/ExportInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextExportInfoTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/ExportInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextExportInfoTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/ExportInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextExportInfoTest.cs (revision c0c23a5508146aad6005fc0eb3b78bab7a63dc63) @@ -0,0 +1,145 @@ +// Copyright (C) Stichting Deltares 2016. 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.Linq; +using Core.Common.Base.IO; +using Core.Common.Gui.Plugin; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.GrassCoverErosionOutwards.Data; +using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; +using Ringtoets.GrassCoverErosionOutwards.Plugin; +using Ringtoets.Revetment.Data; +using Ringtoets.Revetment.IO; + +namespace Ringtoets.GrassCoverErosionOutwards.Forms.Test.ExportInfos +{ + [TestFixture] + public class GrassCoverErosionOutwardsWaveConditionsCalculationContextExportInfoTest + { + [Test] + public void CreateFileExporter_Always_ExpectedPropertiesSet() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(new GrassCoverErosionOutwardsWaveConditionsCalculation(), + failureMechanism, assessmentSection); + using (GrassCoverErosionOutwardsPlugin plugin = new GrassCoverErosionOutwardsPlugin()) + { + ExportInfo exportInfo = GetExportInfo(plugin); + + // Call + IFileExporter fileExporter = exportInfo.CreateFileExporter(context, "test"); + + // Assert + Assert.IsInstanceOf(fileExporter); + } + mocks.VerifyAll(); + } + + [Test] + public void FileFilter_Always_ReturnsFileFilter() + { + // Setup + using (GrassCoverErosionOutwardsPlugin plugin = new GrassCoverErosionOutwardsPlugin()) + { + ExportInfo exportInfo = GetExportInfo(plugin); + + // Call + string fileFilter = exportInfo.FileFilter; + + // Assert + Assert.AreEqual("Kommagescheiden bestand (*.csv)|*.csv", fileFilter); + } + } + + [Test] + public void IsEnabled_GrassCoverErosionOutwardsWaveConditionsCalculationHasOutputFalse_ReturnsFalse() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext(new GrassCoverErosionOutwardsWaveConditionsCalculation(), + failureMechanism, assessmentSection); + using (GrassCoverErosionOutwardsPlugin plugin = new GrassCoverErosionOutwardsPlugin()) + { + ExportInfo exportInfo = GetExportInfo(plugin); + + // Call + bool isEnabled = exportInfo.IsEnabled(context); + + // Assert + Assert.IsFalse(isEnabled); + } + mocks.VerifyAll(); + } + + [Test] + public void IsEnabled_GrassCoverErosionOutwardsWaveConditionsCalculationHasOutputTrue_ReturnsTrue() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var output = new[] + { + new WaveConditionsOutput(1, 0, 3, 5), + new WaveConditionsOutput(8, 2, 6, 1) + }; + + var context = new GrassCoverErosionOutwardsWaveConditionsCalculationContext( + new GrassCoverErosionOutwardsWaveConditionsCalculation + { + Output = new GrassCoverErosionOutwardsWaveConditionsOutput(output) + }, + failureMechanism, assessmentSection); + + using (GrassCoverErosionOutwardsPlugin plugin = new GrassCoverErosionOutwardsPlugin()) + { + ExportInfo exportInfo = GetExportInfo(plugin); + + // Call + bool isEnabled = exportInfo.IsEnabled(context); + + // Assert + Assert.IsTrue(isEnabled); + } + mocks.VerifyAll(); + } + + private static ExportInfo GetExportInfo(GrassCoverErosionOutwardsPlugin plugin) + { + return plugin.GetExportInfos().First(ei => ei.DataType == typeof(GrassCoverErosionOutwardsWaveConditionsCalculationContext)); + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/ExportInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextExportInfoTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/ExportInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextExportInfoTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/ExportInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextExportInfoTest.cs (revision c0c23a5508146aad6005fc0eb3b78bab7a63dc63) @@ -0,0 +1,221 @@ +// Copyright (C) Stichting Deltares 2016. 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.Linq; +using Core.Common.Base.IO; +using Core.Common.Gui.Plugin; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.GrassCoverErosionOutwards.Data; +using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; +using Ringtoets.GrassCoverErosionOutwards.Plugin; +using Ringtoets.Revetment.Data; +using Ringtoets.Revetment.IO; + +namespace Ringtoets.GrassCoverErosionOutwards.Forms.Test.ExportInfos +{ + [TestFixture] + public class GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextExportInfoTest + { + [Test] + public void CreateFileExporter_Always_ExpectedPropertiesSet() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var calculationGroup = new CalculationGroup(); + + var context = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(calculationGroup, failureMechanism, assessmentSection); + using (GrassCoverErosionOutwardsPlugin plugin = new GrassCoverErosionOutwardsPlugin()) + { + ExportInfo exportInfo = GetExportInfo(plugin); + + // Call + IFileExporter fileExporter = exportInfo.CreateFileExporter(context, "test"); + + // Assert + Assert.IsInstanceOf(fileExporter); + } + mocks.VerifyAll(); + } + + [Test] + public void FileFilter_Always_ReturnsFileFilter() + { + // Setup + using (GrassCoverErosionOutwardsPlugin plugin = new GrassCoverErosionOutwardsPlugin()) + { + ExportInfo exportInfo = GetExportInfo(plugin); + + // Call + string fileFilter = exportInfo.FileFilter; + + // Assert + Assert.AreEqual("Kommagescheiden bestand (*.csv)|*.csv", fileFilter); + } + } + + [Test] + public void IsEnabled_NoGrassCoverErosionOutwardsWaveConditionsCalculation_ReturnsFalse() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var calculationGroup = new CalculationGroup(); + + var context = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(calculationGroup, failureMechanism, assessmentSection); + using (GrassCoverErosionOutwardsPlugin plugin = new GrassCoverErosionOutwardsPlugin()) + { + ExportInfo exportInfo = GetExportInfo(plugin); + + // Call + bool isEnabled = exportInfo.IsEnabled(context); + + // Assert + Assert.IsFalse(isEnabled); + } + mocks.VerifyAll(); + } + + [Test] + public void IsEnabled_GrassCoverErosionOutwardsWaveConditionsCalculationHasOutputFalse_ReturnsFalse() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var calculationGroup = new CalculationGroup(); + calculationGroup.Children.Add(new GrassCoverErosionOutwardsWaveConditionsCalculation()); + + var context = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(calculationGroup, failureMechanism, assessmentSection); + using (GrassCoverErosionOutwardsPlugin plugin = new GrassCoverErosionOutwardsPlugin()) + { + ExportInfo exportInfo = GetExportInfo(plugin); + + // Call + bool isEnabled = exportInfo.IsEnabled(context); + + // Assert + Assert.IsFalse(isEnabled); + } + mocks.VerifyAll(); + } + + [Test] + public void IsEnabled_GrassCoverErosionOutwardsWaveConditionsCalculationHasOutputTrue_ReturnsTrue() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var calculationGroup = new CalculationGroup(); + var output = new[] + { + new WaveConditionsOutput(1, 0, 3, 5), + new WaveConditionsOutput(8, 2, 6, 1) + }; + + calculationGroup.Children.Add(new GrassCoverErosionOutwardsWaveConditionsCalculation + { + Output = new GrassCoverErosionOutwardsWaveConditionsOutput(output) + }); + + var context = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(calculationGroup, failureMechanism, assessmentSection); + using (GrassCoverErosionOutwardsPlugin plugin = new GrassCoverErosionOutwardsPlugin()) + { + ExportInfo exportInfo = GetExportInfo(plugin); + + // Call + bool isEnabled = exportInfo.IsEnabled(context); + + // Assert + Assert.IsTrue(isEnabled); + } + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void IsEnabled_GrassCoverErosionOutwardsWaveConditionsCalculationInSubFolder_ReturnsTrueIfHasOutput(bool hasOutput) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var calculationGroup = new CalculationGroup(); + var output = new[] + { + new WaveConditionsOutput(1, 0, 3, 5), + new WaveConditionsOutput(8, 2, 6, 1) + }; + + GrassCoverErosionOutwardsWaveConditionsOutput grassCoverErosionOutwardsWaveConditionsOutput = null; + if (hasOutput) + { + grassCoverErosionOutwardsWaveConditionsOutput = new GrassCoverErosionOutwardsWaveConditionsOutput(output); + } + calculationGroup.Children.Add( + new CalculationGroup + { + Children = + { + new GrassCoverErosionOutwardsWaveConditionsCalculation + { + Output = grassCoverErosionOutwardsWaveConditionsOutput + } + } + }); + + var context = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(calculationGroup, failureMechanism, assessmentSection); + using (GrassCoverErosionOutwardsPlugin plugin = new GrassCoverErosionOutwardsPlugin()) + { + ExportInfo exportInfo = GetExportInfo(plugin); + + // Call + bool isEnabled = exportInfo.IsEnabled(context); + + // Assert + Assert.AreEqual(hasOutput, isEnabled); + } + mocks.VerifyAll(); + } + + private static ExportInfo GetExportInfo(GrassCoverErosionOutwardsPlugin plugin) + { + return plugin.GetExportInfos().First(ei => ei.DataType == typeof(GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext)); + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/ExportInfos/HydraulicBoundariesGroupContextExportInfoTest.cs =================================================================== diff -u -rfc223d32f6132020b12178aada14864c210176c4 -rc0c23a5508146aad6005fc0eb3b78bab7a63dc63 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/ExportInfos/HydraulicBoundariesGroupContextExportInfoTest.cs (.../HydraulicBoundariesGroupContextExportInfoTest.cs) (revision fc223d32f6132020b12178aada14864c210176c4) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/ExportInfos/HydraulicBoundariesGroupContextExportInfoTest.cs (.../HydraulicBoundariesGroupContextExportInfoTest.cs) (revision c0c23a5508146aad6005fc0eb3b78bab7a63dc63) @@ -22,118 +22,245 @@ using System.Linq; using Core.Common.Base.IO; using Core.Common.Gui.Plugin; +using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.IO; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; +using Ringtoets.GrassCoverErosionOutwards.IO; using Ringtoets.GrassCoverErosionOutwards.Plugin; using Ringtoets.HydraRing.Data; +using Ringtoets.Revetment.Data; using RingtoetsCommonIoResources = Ringtoets.Common.IO.Properties.Resources; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.GrassCoverErosionOutwards.Forms.Test.ExportInfos { [TestFixture] public class HydraulicBoundariesGroupContextExportInfoTest { + private ExportInfo hydraulicBoundaryLocationsExporterExportInfo; + private ExportInfo waveConditionsExporterExportInfo; + + [SetUp] + public void Setup() + { + using (GrassCoverErosionOutwardsPlugin plugin = new GrassCoverErosionOutwardsPlugin()) + { + ExportInfo[] exportInfos = plugin.GetExportInfos().Where(ei => ei.DataType == typeof(HydraulicBoundariesGroupContext)).ToArray(); + hydraulicBoundaryLocationsExporterExportInfo = exportInfos.FirstOrDefault(ei => ei.Name.Equals("Waterstanden en golfhoogten uit marginale statistiek (*.shp).")); + waveConditionsExporterExportInfo = exportInfos.FirstOrDefault(ei => ei.Name.Equals("Berekende belastingen bij verschillende waterstanden (*.csv).")); + } + } + [Test] - public void Initialized_Always_ExpectedPropertiesSet() + public void HydraulicBoundaryLocationsExporterExportInfo_Name_Exists() { + // Assert + Assert.IsNotNull(hydraulicBoundaryLocationsExporterExportInfo); + } + + [Test] + public void HydraulicBoundaryLocationsExporterExportInfo_Category_GeneralCategory() + { + // Assert + Assert.AreEqual("Algemeen", hydraulicBoundaryLocationsExporterExportInfo.Category); + } + + [Test] + public void HydraulicBoundaryLocationsExporterExportInfo_Image_ReturnsPointShapefileIcon() + { + // Call + var icon = hydraulicBoundaryLocationsExporterExportInfo.Image; + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.PointShapefileIcon, icon); + } + + [Test] + public void HydraulicBoundaryLocationsExporterExportInfo_CreateFileExporter_IsInstanceOfHydraulicBoundaryLocationsExporter() + { // Setup var mockRepository = new MockRepository(); - var assessmentSectionMock = mockRepository.StrictMock(); + var assessmentSectionMock = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); - string filePath = "test"; - using (GrassCoverErosionOutwardsPlugin plugin = new GrassCoverErosionOutwardsPlugin()) - { - ExportInfo info = GetInfo(plugin); + // Call + IFileExporter fileExporter = hydraulicBoundaryLocationsExporterExportInfo.CreateFileExporter(context, "test"); - // Call - IFileExporter fileExporter = info.CreateFileExporter(context, filePath); + // Assert + Assert.IsInstanceOf(fileExporter); + mockRepository.VerifyAll(); + } - // Assert - Assert.IsInstanceOf(fileExporter); - mockRepository.VerifyAll(); - } + [Test] + public void IsEnabled_HydraulicBoundaryLocationsEmpty_ReturnsFalse() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSectionMock = mockRepository.Stub(); + mockRepository.ReplayAll(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); + + // Call + bool isEnabled = hydraulicBoundaryLocationsExporterExportInfo.IsEnabled(context); + + // Assert + Assert.IsFalse(isEnabled); } [Test] - public void FileFilter_Always_ReturnsFileFilter() + public void IsEnabled_HydraulicBoundaryLocationsNotEmpty_ReturnsTrue() { // Setup - using (GrassCoverErosionOutwardsPlugin plugin = new GrassCoverErosionOutwardsPlugin()) + var mockRepository = new MockRepository(); + var assessmentSectionMock = mockRepository.Stub(); + mockRepository.ReplayAll(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + failureMechanism.SetGrassCoverErosionOutwardsHydraulicBoundaryLocations(new HydraulicBoundaryDatabase { - ExportInfo info = GetInfo(plugin); + Locations = + { + new HydraulicBoundaryLocation(0, "aName", 0, 0) + } + }); - // Call - string fileFilter = info.FileFilter; + var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); - // Assert - Assert.AreEqual(RingtoetsCommonIoResources.DataTypeDisplayName_shape_file_filter, fileFilter); - } + // Call + bool isEnabled = hydraulicBoundaryLocationsExporterExportInfo.IsEnabled(context); + + // Assert + Assert.IsTrue(isEnabled); } [Test] - public void IsEnabled_GrassCoverErosionOutwardsHydraulicBoundaryLocationsEmpty_ReturnsFalse() + public void HydraulicBoundaryLocationsExporterExportInfo_FileFilter_ShpFileFilter() { + // Call + string fileFilter = hydraulicBoundaryLocationsExporterExportInfo.FileFilter; + + // Assert + Assert.AreEqual("Shapebestand (*.shp)|*.shp", fileFilter); + } + + [Test] + public void WaveConditionsExporterExportInfo_Name_Exists() + { + // Assert + Assert.IsNotNull(waveConditionsExporterExportInfo); + } + + [Test] + public void WaveConditionsExporterExportInfo_Category_GeneralCategory() + { + // Assert + Assert.AreEqual("Algemeen", waveConditionsExporterExportInfo.Category); + } + + [Test] + public void WaveConditionsExporterExportInfo_Image_ReturnsCsvFileIcon() + { + // Call + var icon = waveConditionsExporterExportInfo.Image; + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CsvFileIcon, icon); + } + + [Test] + public void WaveConditionsExporterExportInfo_IsInstanceOfGrassCoverErosionOutwardsWaveConditionsExporter() + { // Setup var mockRepository = new MockRepository(); - var assessmentSectionMock = mockRepository.StrictMock(); + var assessmentSectionMock = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); - using (GrassCoverErosionOutwardsPlugin plugin = new GrassCoverErosionOutwardsPlugin()) - { - ExportInfo info = GetInfo(plugin); + // Call + IFileExporter fileExporter = waveConditionsExporterExportInfo.CreateFileExporter(context, "test"); - // Call - bool isEnabled = info.IsEnabled(context); + // Assert + Assert.IsInstanceOf(fileExporter); + mockRepository.VerifyAll(); + } - // Assert - Assert.IsFalse(isEnabled); - } + [Test] + public void IsEnabled_WaveConditionsCalculationGroupCalculationsEmpty_ReturnsFalse() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSectionMock = mockRepository.Stub(); + mockRepository.ReplayAll(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); + + // Call + bool isEnabled = waveConditionsExporterExportInfo.IsEnabled(context); + + // Assert + Assert.IsFalse(isEnabled); } [Test] - public void IsEnabled_GrassCoverErosionOutwardsHydraulicBoundaryLocationsNotEmpty_ReturnsTrue() + public void IsEnabled_CalculationsWithoutOutput_ReturnsFalse() { // Setup var mockRepository = new MockRepository(); - var assessmentSectionMock = mockRepository.StrictMock(); + var assessmentSectionMock = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.SetGrassCoverErosionOutwardsHydraulicBoundaryLocations(new HydraulicBoundaryDatabase - { - Locations = - { - new HydraulicBoundaryLocation(0, "aName", 0, 0) - } - }); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(new GrassCoverErosionOutwardsWaveConditionsCalculation()); var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); - using (GrassCoverErosionOutwardsPlugin plugin = new GrassCoverErosionOutwardsPlugin()) + // Call + bool isEnabled = waveConditionsExporterExportInfo.IsEnabled(context); + + // Assert + Assert.IsFalse(isEnabled); + } + + [Test] + public void IsEnabled_CalculationsWithOutput_ReturnsTrue() + { + // Setup + var mockRepository = new MockRepository(); + var assessmentSectionMock = mockRepository.Stub(); + mockRepository.ReplayAll(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + failureMechanism.WaveConditionsCalculationGroup.Children.Add(new GrassCoverErosionOutwardsWaveConditionsCalculation { - ExportInfo info = GetInfo(plugin); + Output = new GrassCoverErosionOutwardsWaveConditionsOutput(Enumerable.Empty()) + }); - // Call - bool isEnabled = info.IsEnabled(context); + var context = new HydraulicBoundariesGroupContext(failureMechanism, assessmentSectionMock); - // Assert - Assert.IsTrue(isEnabled); - } + // Call + bool isEnabled = waveConditionsExporterExportInfo.IsEnabled(context); + + // Assert + Assert.IsTrue(isEnabled); } - private static ExportInfo GetInfo(GrassCoverErosionOutwardsPlugin plugin) + [Test] + public void WaveConditionsExporterExportInfo_FileFilter_CsvFileFilter() { - return plugin.GetExportInfos().First(ei => ei.DataType == typeof(HydraulicBoundariesGroupContext)); + // Call + string fileFilter = waveConditionsExporterExportInfo.FileFilter; + + // Assert + Assert.AreEqual("Kommagescheiden bestand (*.csv)|*.csv", fileFilter); } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj =================================================================== diff -u -rea2368484b660a126d429d51879bca9d6168c135 -rc0c23a5508146aad6005fc0eb3b78bab7a63dc63 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision ea2368484b660a126d429d51879bca9d6168c135) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision c0c23a5508146aad6005fc0eb3b78bab7a63dc63) @@ -61,6 +61,8 @@ Properties\GlobalAssembly.cs + + @@ -175,6 +177,10 @@ {AF1ACFA2-AEE5-4DB7-98CA-8B3720E46AD9} Ringtoets.Revetment.Forms + + {e3347b16-bb18-41c1-8d34-fbcbf20db695} + Ringtoets.Revetment.IO + {EA416DD2-1633-439E-8512-B9933E37B9C5} Ringtoets.Revetment.Service.TestUtil @@ -187,6 +193,10 @@ {41B829C1-630F-40B0-8BEE-B1C4C94EC8C4} Ringtoets.GrassCoverErosionOutwards.Forms + + {6EAEEC05-E564-45FC-AE7E-912F3612CC9D} + Ringtoets.GrassCoverErosionOutwards.IO + {9B3ED064-E29F-4D38-85E0-3A82B77BA702} Ringtoets.GrassCoverErosionOutwards.Plugin Fisheye: Tag c0c23a5508146aad6005fc0eb3b78bab7a63dc63 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/ExportInfos/GrassCoverErosionOutwardsWaveConditionsCalculationContextExportInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag c0c23a5508146aad6005fc0eb3b78bab7a63dc63 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/ExportInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextExportInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -r254f70f60d07ff9d8778b270f80a4910cb71c053 -rc0c23a5508146aad6005fc0eb3b78bab7a63dc63 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 254f70f60d07ff9d8778b270f80a4910cb71c053) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision c0c23a5508146aad6005fc0eb3b78bab7a63dc63) @@ -66,8 +66,6 @@ - - @@ -202,10 +200,6 @@ {73E7E100-C015-4874-A548-AD6E33E7955E} Ringtoets.Common.Service.TestUtil - - {9B3ED064-E29F-4D38-85E0-3A82B77BA702} - Ringtoets.GrassCoverErosionOutwards.Plugin - {888d4097-8bc2-4703-9fb1-8744c94d525e} Ringtoets.HydraRing.Calculation