Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs =================================================================== diff -u -r6b90ee376ad7c864fdfe6d39cf8e6900f741a212 -r7ee2bf67507878c09c5c587c38e6c82e5e213720 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 6b90ee376ad7c864fdfe6d39cf8e6900f741a212) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 7ee2bf67507878c09c5c587c38e6c82e5e213720) @@ -43,14 +43,15 @@ using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.PropertyClasses; using Ringtoets.Piping.Forms.Views; +using Ringtoets.Piping.IO.Exporters; using Ringtoets.Piping.IO.Importers; using Ringtoets.Piping.Plugin.FileImporter; +using Ringtoets.Piping.Plugin.Properties; using Ringtoets.Piping.Primitives; using Ringtoets.Piping.Service; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources; -using PipingPluginResources = Ringtoets.Piping.Plugin.Properties.Resources; namespace Ringtoets.Piping.Plugin { @@ -115,6 +116,20 @@ }; } + public override IEnumerable GetExportInfos() + { + yield return new ExportInfo + { + Name = Resources.PipingPlugin_GetExportInfos_calculation_configuration_file_description, + Category = RingtoetsCommonFormsResources.Ringtoets_Category, + Image = RingtoetsCommonFormsResources.GeneralFolderIcon, + FileFilter = new ExpectedFile(Resources.PipingPlugin_GetExportInfos_xml_extension, + Resources.PipingPlugin_GetExportInfos_calculation_configuration_file_description), + CreateFileExporter = (context, filePath) => new PipingConfigurationExporter(context.WrappedData, filePath), + IsEnabled = context => context.WrappedData.Children.Any() + }; + } + public override IEnumerable GetUpdateInfos() { yield return new UpdateInfo @@ -156,7 +171,7 @@ { get { - return new ExpectedFile(PipingPluginResources.Soil_file_Extension, PipingPluginResources.Soil_file_Description); + return new ExpectedFile(Resources.Soil_file_Extension, Resources.Soil_file_Description); } } Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs =================================================================== diff -u -r392383a267a69010698aef6948b1e53c6a889bae -r7ee2bf67507878c09c5c587c38e6c82e5e213720 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 392383a267a69010698aef6948b1e53c6a889bae) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 7ee2bf67507878c09c5c587c38e6c82e5e213720) @@ -82,6 +82,24 @@ } /// + /// Looks up a localized string similar to Ringtoets berekeningen configuratie.. + /// + public static string PipingPlugin_GetExportInfos_calculation_configuration_file_description { + get { + return ResourceManager.GetString("PipingPlugin_GetExportInfos_calculation_configuration_file_description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to xml. + /// + public static string PipingPlugin_GetExportInfos_xml_extension { + get { + return ResourceManager.GetString("PipingPlugin_GetExportInfos_xml_extension", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Bijwerken van stochastische ondergrondmodellen.. /// public static string PipingPlugin_RunUpdateStochasticSoilModel_Update_StochasticSoilModels { Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx =================================================================== diff -u -r392383a267a69010698aef6948b1e53c6a889bae -r7ee2bf67507878c09c5c587c38e6c82e5e213720 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 392383a267a69010698aef6948b1e53c6a889bae) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 7ee2bf67507878c09c5c587c38e6c82e5e213720) @@ -225,4 +225,10 @@ Het bijwerken van de profielschematisaties is mislukt. + + xml + + + Ringtoets berekeningen configuratie. + \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationGroupContextExportInfoTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationGroupContextExportInfoTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationGroupContextExportInfoTest.cs (revision 7ee2bf67507878c09c5c587c38e6c82e5e213720) @@ -0,0 +1,154 @@ +// 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; +using Core.Common.Gui.Plugin; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Forms.PresentationObjects; +using Ringtoets.Piping.IO.Exporters; +using Ringtoets.Piping.Primitives; + +namespace Ringtoets.Piping.Plugin.Test.ExportInfos +{ + [TestFixture] + public class PipingCalculationGroupContextExportInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var context = new PipingCalculationGroupContext(new CalculationGroup(), + Enumerable.Empty(), + Enumerable.Empty(), + new PipingFailureMechanism(), + assessmentSection); + + using (PipingPlugin plugin = new PipingPlugin()) + { + ExportInfo info = GetExportInfo(plugin); + + // Call + IFileExporter fileExporter = info.CreateFileExporter(context, "test"); + + // Assert + Assert.IsInstanceOf(fileExporter); + } + mocks.VerifyAll(); + } + + [Test] + public void FileFilter_Always_ReturnFileFilter() + { + // Setup + using (PipingPlugin plugin = new PipingPlugin()) + { + ExportInfo info = GetExportInfo(plugin); + + // Call + ExpectedFile fileFilter = info.FileFilter; + + // Assert + Assert.AreEqual("Ringtoets berekeningen configuratie. (*.xml)|*.xml", fileFilter.Filter); + } + } + + [Test] + public void IsEnabled_CalculationGroupNoChildren_ReturnFalse() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var context = new PipingCalculationGroupContext(new CalculationGroup(), + Enumerable.Empty(), + Enumerable.Empty(), + new PipingFailureMechanism(), + assessmentSection); + + using (PipingPlugin plugin = new PipingPlugin()) + { + ExportInfo info = GetExportInfo(plugin); + + // Call + bool isEnabled = info.IsEnabled(context); + + // Assert + Assert.IsFalse(isEnabled); + } + } + + [Test] + [TestCase(true, false)] + [TestCase(false, true)] + public void IsEnabled_CalculationGroupWithChildren_ReturnTrue(bool hasNestedGroup, bool hasCalculation) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var calculationGroup = new CalculationGroup(); + + if (hasNestedGroup) + { + calculationGroup.Children.Add(new CalculationGroup()); + } + + if (hasCalculation) + { + calculationGroup.Children.Add(new PipingCalculation(new GeneralPipingInput())); + } + + var context = new PipingCalculationGroupContext(calculationGroup, + Enumerable.Empty(), + Enumerable.Empty(), + new PipingFailureMechanism(), + assessmentSection); + + using (PipingPlugin plugin = new PipingPlugin()) + { + ExportInfo info = GetExportInfo(plugin); + + // Call + bool isEnabled = info.IsEnabled(context); + + // Assert + Assert.IsTrue(isEnabled); + } + } + + private static ExportInfo GetExportInfo(PipingPlugin plugin) + { + return plugin.GetExportInfos().First(ei => ei.DataType == typeof(PipingCalculationGroupContext)); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj =================================================================== diff -u -rf7cf0aa90e0d435fc03c42790368ad02a0889411 -r7ee2bf67507878c09c5c587c38e6c82e5e213720 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision f7cf0aa90e0d435fc03c42790368ad02a0889411) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision 7ee2bf67507878c09c5c587c38e6c82e5e213720) @@ -72,6 +72,7 @@ Properties\GlobalAssembly.cs +