Fisheye: Tag 82247f1951bfa0cf5a813f684d2cc05019bbe917 refers to a dead (removed) revision in file `Riskeer/Piping/src/Riskeer.Piping.Forms/ImportInfos/PipingImportInfoFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Piping/src/Riskeer.Piping.Plugin/ImportInfos/PipingImportInfoFactory.cs =================================================================== diff -u --- Riskeer/Piping/src/Riskeer.Piping.Plugin/ImportInfos/PipingImportInfoFactory.cs (revision 0) +++ Riskeer/Piping/src/Riskeer.Piping.Plugin/ImportInfos/PipingImportInfoFactory.cs (revision 82247f1951bfa0cf5a813f684d2cc05019bbe917) @@ -0,0 +1,69 @@ +// 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 System.Linq; +using Core.Common.Gui.Plugin; +using Core.Common.Util; +using Riskeer.Common.IO.FileImporters; +using Riskeer.Common.IO.FileImporters.MessageProviders; +using Riskeer.Piping.Forms.PresentationObjects; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; +using RiskeerCommonIOResources = Riskeer.Common.IO.Properties.Resources; + +namespace Riskeer.Piping.Plugin.ImportInfos +{ + /// + /// Factory for creating standard objects. + /// + public static class PipingImportInfoFactory + { + /// + /// Creates a object for a . + /// + /// The + /// to use in the importer. + /// An object. + /// Thrown when + /// is null. + public static ImportInfo CreateFailureMechanismSectionsImportInfo( + IFailureMechanismSectionUpdateStrategy updateStrategy) + { + if (updateStrategy == null) + { + throw new ArgumentNullException(nameof(updateStrategy)); + } + + return new ImportInfo + { + 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.AssessmentSection.ReferenceLine.Points.Any(), + CreateFileImporter = (context, filePath) => new FailureMechanismSectionsImporter( + context.WrappedData, context.AssessmentSection.ReferenceLine, + filePath, updateStrategy, new ImportMessageProvider()) + }; + } + } +} \ No newline at end of file Fisheye: Tag 82247f1951bfa0cf5a813f684d2cc05019bbe917 refers to a dead (removed) revision in file `Riskeer/Piping/test/Riskeer.Piping.Forms.Test/ImportInfos/PipingImportInfoFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/ImportInfos/PipingImportInfoFactoryTest.cs =================================================================== diff -u --- Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/ImportInfos/PipingImportInfoFactoryTest.cs (revision 0) +++ Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/ImportInfos/PipingImportInfoFactoryTest.cs (revision 82247f1951bfa0cf5a813f684d2cc05019bbe917) @@ -0,0 +1,90 @@ +// 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.Base.Geometry; +using Core.Common.Gui.Plugin; +using Core.Common.TestUtil; +using Core.Common.Util; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.IO.FileImporters; +using Riskeer.Piping.Data; +using Riskeer.Piping.Forms.PresentationObjects; +using Riskeer.Piping.Plugin.ImportInfos; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.Piping.Plugin.Test.ImportInfos +{ + [TestFixture] + public class PipingImportInfoFactoryTest + { + [Test] + public void CreateFailureMechanismSectionsImportInfo_UpdateStrategyNull_ThrowsArgumentNullException() + { + // Call + void Call() => PipingImportInfoFactory.CreateFailureMechanismSectionsImportInfo(null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("updateStrategy", exception.ParamName); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void CreateFailureMechanismSectionsImportInfo_WithData_ReturnsImportInfo(bool isEnabled) + { + // Setup + var mocks = new MockRepository(); + var updateStrategy = mocks.Stub(); + mocks.ReplayAll(); + + var assessmentSection = new AssessmentSectionStub(); + if (isEnabled) + { + assessmentSection.ReferenceLine.SetGeometry(new[] + { + new Point2D(0, 0) + }); + } + + // Call + ImportInfo importInfo = PipingImportInfoFactory.CreateFailureMechanismSectionsImportInfo(updateStrategy); + + // Assert + Assert.AreEqual("Vakindeling", importInfo.Name); + Assert.AreEqual("Algemeen", importInfo.Category); + + FileFilterGenerator fileFilterGenerator = importInfo.FileFilterGenerator; + Assert.AreEqual("Shapebestand (*.shp)|*.shp", fileFilterGenerator.Filter); + + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.SectionsIcon, importInfo.Image); + + var context = new PipingFailureMechanismSectionsContext(new PipingFailureMechanism(), assessmentSection); + Assert.AreEqual(isEnabled, importInfo.IsEnabled(context)); + Assert.IsInstanceOf(importInfo.CreateFileImporter(context, "")); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file