Index: Riskeer/Piping/src/Riskeer.Piping.Plugin/UpdateInfos/PipingUpdateInfoFactory.cs =================================================================== diff -u --- Riskeer/Piping/src/Riskeer.Piping.Plugin/UpdateInfos/PipingUpdateInfoFactory.cs (revision 0) +++ Riskeer/Piping/src/Riskeer.Piping.Plugin/UpdateInfos/PipingUpdateInfoFactory.cs (revision 77da9d16daecbde13e5ff5270ce21f5aa1311b06) @@ -0,0 +1,65 @@ +// Copyright (C) Stichting Deltares 2019. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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; +using Core.Common.Gui.Plugin; +using Core.Common.Util; +using Riskeer.Common.IO.FileImporters; +using Riskeer.Common.IO.FileImporters.MessageProviders; +using Riskeer.Piping.Data; +using Riskeer.Piping.Forms.PresentationObjects; +using Riskeer.Piping.Plugin.FileImporter; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; +using RiskeerCommonIOResources = Riskeer.Common.IO.Properties.Resources; + +namespace Riskeer.Piping.Plugin.UpdateInfos +{ + /// + /// Factory for creating objects. + /// + public static class PipingUpdateInfoFactory + { + /// + /// Creates a object for a . + /// + /// An object. + public static UpdateInfo CreateFailureMechanismSectionsUpdateInfo() + { + return new UpdateInfo + { + Name = RiskeerCommonFormsResources.FailureMechanismSections_DisplayName, + Category = RiskeerCommonFormsResources.Riskeer_Category, + Image = RiskeerCommonFormsResources.SectionsIcon, + FileFilterGenerator = new FileFilterGenerator(RiskeerCommonIOResources.Shape_file_filter_Extension, + RiskeerCommonIOResources.Shape_file_filter_Description), + IsEnabled = context => context.WrappedData.FailureMechanismSectionSourcePath != null, + CurrentPath = context => context.WrappedData.FailureMechanismSectionSourcePath, + CreateFileImporter = (context, filePath) => new FailureMechanismSectionsImporter( + context.WrappedData, + context.AssessmentSection.ReferenceLine, + filePath, + new PipingFailureMechanismSectionUpdateStrategy((PipingFailureMechanism) context.WrappedData, + new PipingFailureMechanismSectionResultUpdateStrategy()), + new UpdateMessageProvider()) + }; + } + } +} \ No newline at end of file Index: Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/UpdateInfos/PipingUpdateInfoFactoryTest.cs =================================================================== diff -u --- Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/UpdateInfos/PipingUpdateInfoFactoryTest.cs (revision 0) +++ Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/UpdateInfos/PipingUpdateInfoFactoryTest.cs (revision 77da9d16daecbde13e5ff5270ce21f5aa1311b06) @@ -0,0 +1,68 @@ +// Copyright (C) Stichting Deltares 2019. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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 Core.Common.Gui.Plugin; +using Core.Common.TestUtil; +using Core.Common.Util; +using NUnit.Framework; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.IO.FileImporters; +using Riskeer.Piping.Data; +using Riskeer.Piping.Data.TestUtil; +using Riskeer.Piping.Forms.PresentationObjects; +using Riskeer.Piping.Plugin.UpdateInfos; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.Piping.Plugin.Test.UpdateInfos +{ + [TestFixture] + public class PipingUpdateInfoFactoryTest + { + [Test] + [TestCase(true)] + [TestCase(false)] + public void CreateFailureMechanismSectionsImportInfo_WithData_ReturnsImportInfo(bool isEnabled) + { + // Setup + PipingFailureMechanism failureMechanism = isEnabled + ? TestPipingFailureMechanism.GetFailureMechanismWithSurfaceLinesAndStochasticSoilModels() + : new PipingFailureMechanism(); + + var context = new PipingFailureMechanismSectionsContext(failureMechanism, new AssessmentSectionStub()); + + // Call + UpdateInfo updateInfo = PipingUpdateInfoFactory.CreateFailureMechanismSectionsUpdateInfo(); + + // Assert + Assert.AreEqual("Vakindeling", updateInfo.Name); + Assert.AreEqual("Algemeen", updateInfo.Category); + + FileFilterGenerator fileFilterGenerator = updateInfo.FileFilterGenerator; + Assert.AreEqual("Shapebestand (*.shp)|*.shp", fileFilterGenerator.Filter); + + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.SectionsIcon, updateInfo.Image); + + Assert.AreEqual(failureMechanism.FailureMechanismSectionSourcePath, updateInfo.CurrentPath(context)); + Assert.AreEqual(isEnabled, updateInfo.IsEnabled(context)); + Assert.IsInstanceOf(updateInfo.CreateFileImporter(context, "")); + } + } +} \ No newline at end of file