Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs =================================================================== diff -u -r38e69a97ab7003d46b9ac16660b9cb396308ac47 -r4ce9ecef7e93f14065e8a0c79a81ce43ab2f4c0f --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 38e69a97ab7003d46b9ac16660b9cb396308ac47) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 4ce9ecef7e93f14065e8a0c79a81ce43ab2f4c0f) @@ -104,7 +104,7 @@ CreateFileExporter = (context, filePath) => new GrassCoverErosionInwardsCalculationConfigurationExporter(new[] { context.WrappedData - }, filePath), + }, filePath) }; } Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs =================================================================== diff -u -r38e69a97ab7003d46b9ac16660b9cb396308ac47 -r4ce9ecef7e93f14065e8a0c79a81ce43ab2f4c0f --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 38e69a97ab7003d46b9ac16660b9cb396308ac47) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 4ce9ecef7e93f14065e8a0c79a81ce43ab2f4c0f) @@ -139,6 +139,14 @@ CreateFileExporter = (context, filePath) => new PipingCalculationConfigurationExporter(context.WrappedData.Children, filePath), IsEnabled = context => context.WrappedData.Children.Any() }; + yield return new ExportInfo + { + FileFilterGenerator = PipingCalculationConfigurationFileFilter, + CreateFileExporter = (context, filePath) => new PipingCalculationConfigurationExporter(new[] + { + context.WrappedData + }, filePath) + }; } public override IEnumerable GetUpdateInfos() @@ -720,7 +728,8 @@ StrictContextMenuItem updateEntryAndExitPoint = CreateUpdateEntryAndExitPointItem(nodeData); - return builder.AddRenameItem() + return builder.AddExportItem() + .AddRenameItem() .AddCustomItem(updateEntryAndExitPoint) .AddValidateCalculationItem( nodeData, Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationContextExportInfoTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationContextExportInfoTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ExportInfos/PipingCalculationContextExportInfoTest.cs (revision 4ce9ecef7e93f14065e8a0c79a81ce43ab2f4c0f) @@ -0,0 +1,135 @@ +// 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 Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Forms.PresentationObjects; +using Ringtoets.Piping.IO.Exporters; +using Ringtoets.Piping.Primitives; +using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources; + +namespace Ringtoets.Piping.Plugin.Test.ExportInfos +{ + [TestFixture] + public class PipingCalculationContextExportInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new PipingPlugin()) + { + // Call + ExportInfo info = GetExportInfo(plugin); + + // Assert + Assert.IsNotNull(info.CreateFileExporter); + Assert.IsNotNull(info.IsEnabled); + Assert.IsNull(info.Name); + Assert.AreEqual("Algemeen", info.Category); + TestHelper.AssertImagesAreEqual(CoreCommonGuiResources.ExportIcon, info.Image); + Assert.IsNotNull(info.FileFilterGenerator); + } + } + + [Test] + public void CreateFileExporter_Always_ReturnFileExporter() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var context = new PipingCalculationScenarioContext(new PipingCalculationScenario(new GeneralPipingInput()), + Enumerable.Empty(), + Enumerable.Empty(), + new PipingFailureMechanism(), + assessmentSection); + + using (var plugin = new PipingPlugin()) + { + ExportInfo info = GetExportInfo(plugin); + + // Call + IFileExporter fileExporter = info.CreateFileExporter(context, "test"); + + // Assert + Assert.IsInstanceOf(fileExporter); + } + mocks.VerifyAll(); + } + + [Test] + public void FileFilterGenerator_Always_ReturnFileFilter() + { + // Setup + using (var plugin = new PipingPlugin()) + { + ExportInfo info = GetExportInfo(plugin); + + // Call + FileFilterGenerator fileFilterGenerator = info.FileFilterGenerator; + + // Assert + Assert.AreEqual("Ringtoets berekeningenconfiguratie (*.xml)|*.xml", fileFilterGenerator.Filter); + } + } + + [Test] + public void IsEnabled_Always_ReturnTrue() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var context = new PipingCalculationScenarioContext(new PipingCalculationScenario(new GeneralPipingInput()), + Enumerable.Empty(), + Enumerable.Empty(), + new PipingFailureMechanism(), + assessmentSection); + + using (var plugin = new PipingPlugin()) + { + ExportInfo info = GetExportInfo(plugin); + + // Call + bool isEnabled = info.IsEnabled(context); + + // Assert + Assert.IsTrue(isEnabled); + } + mocks.VerifyAll(); + } + + private static ExportInfo GetExportInfo(PipingPlugin plugin) + { + return plugin.GetExportInfos().First(ei => ei.DataType == typeof(PipingCalculationScenarioContext)); + } + } +} \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingPluginTest.cs =================================================================== diff -u -r5f1d410a44f7895c3519e5763497dc30ec492a73 -r4ce9ecef7e93f14065e8a0c79a81ce43ab2f4c0f --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision 5f1d410a44f7895c3519e5763497dc30ec492a73) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision 4ce9ecef7e93f14065e8a0c79a81ce43ab2f4c0f) @@ -194,8 +194,9 @@ ExportInfo[] exportInfos = plugin.GetExportInfos().ToArray(); // Assert - Assert.AreEqual(1, exportInfos.Length); + Assert.AreEqual(2, exportInfos.Length); Assert.IsTrue(exportInfos.Any(tni => tni.DataType == typeof(PipingCalculationGroupContext))); + Assert.IsTrue(exportInfos.Any(tni => tni.DataType == typeof(PipingCalculationScenarioContext))); } } } Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj =================================================================== diff -u -r7271c497cf19130a691b0b07abe99621957fda2e -r4ce9ecef7e93f14065e8a0c79a81ce43ab2f4c0f --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision 7271c497cf19130a691b0b07abe99621957fda2e) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision 4ce9ecef7e93f14065e8a0c79a81ce43ab2f4c0f) @@ -73,6 +73,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs =================================================================== diff -u -rcd2a8d4da88b91f4c947e820b2f19a3892a25b77 -r4ce9ecef7e93f14065e8a0c79a81ce43ab2f4c0f --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs (.../PipingCalculationScenarioContextTreeNodeInfoTest.cs) (revision cd2a8d4da88b91f4c947e820b2f19a3892a25b77) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs (.../PipingCalculationScenarioContextTreeNodeInfoTest.cs) (revision 4ce9ecef7e93f14065e8a0c79a81ce43ab2f4c0f) @@ -53,11 +53,11 @@ [TestFixture] public class PipingCalculationScenarioContextTreeNodeInfoTest : NUnitFormTest { - private const int contextMenuUpdateEntryAndExitPointIndex = 1; + private const int contextMenuUpdateEntryAndExitPointIndex = 2; - private const int contextMenuValidateIndex = 2; - private const int contextMenuCalculateIndex = 3; - private const int contextMenuClearIndex = 5; + private const int contextMenuValidateIndex = 3; + private const int contextMenuCalculateIndex = 4; + private const int contextMenuClearIndex = 6; private MockRepository mocks; private PipingPlugin plugin; @@ -360,6 +360,7 @@ var menuBuilderMock = mocks.Stub(); using (mocks.Ordered()) { + menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddRenameItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);