// 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.Collections.Generic;
using System.Linq;
using Core.Common.Base.Data;
using Core.Common.Base.Geometry;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.HydraRing.Data;
using Ringtoets.Integration.Data;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.KernelWrapper.TestUtil;
using Ringtoets.Piping.Primitives;
namespace Application.Ringtoets.Storage.TestUtil
{
///
/// This class can be used to create instances which have their properties set and can be used in tests.
///
public static class RingtoetsProjectHelper
{
///
/// Returns a new complete instance of .
///
/// A new complete instance of .
public static Project GetFullTestProject()
{
ReferenceLine referenceLine = GetReferenceLine();
Point2D[] referenceLineGeometryPoints = referenceLine.Points.ToArray();
var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
{
Name = "assessmentSection",
HydraulicBoundaryDatabase = GetHydraulicBoundaryDatabase(),
ReferenceLine = referenceLine,
PipingFailureMechanism =
{
StochasticSoilModels =
{
new StochasticSoilModel(-1, "modelName", "modelSegmentName")
{
Geometry =
{
referenceLineGeometryPoints[1],
referenceLineGeometryPoints[2],
referenceLineGeometryPoints[3]
},
StochasticSoilProfiles =
{
new StochasticSoilProfile(0.2, SoilProfileType.SoilProfile1D, -1)
{
SoilProfile = new TestPipingSoilProfile()
},
new StochasticSoilProfile(0.8, SoilProfileType.SoilProfile1D, -1)
{
SoilProfile = new TestPipingSoilProfile()
}
}
}
},
SurfaceLines =
{
GetSurfaceLine()
},
CalculationsGroup =
{
Children =
{
new CalculationGroup
{
Name = "A"
},
new CalculationGroup
{
Name = "B"
}
}
}
}
};
var fullTestProject = new Project
{
Name = "tempProjectFile",
Description = "description",
Items =
{
assessmentSection
}
};
AddSections(assessmentSection.PipingFailureMechanism);
AddSections(assessmentSection.GrassCoverErosionInwards);
AddSections(assessmentSection.MacrostabilityInwards);
AddSections(assessmentSection.MacrostabilityOutwards);
AddSections(assessmentSection.Microstability);
AddSections(assessmentSection.StabilityStoneCover);
AddSections(assessmentSection.WaveImpactAsphaltCover);
AddSections(assessmentSection.WaterPressureAsphaltCover);
AddSections(assessmentSection.GrassCoverErosionOutwards);
AddSections(assessmentSection.GrassCoverSlipOffOutwards);
AddSections(assessmentSection.GrassCoverSlipOffInwards);
AddSections(assessmentSection.HeightStructures);
AddSections(assessmentSection.ClosingStructure);
AddSections(assessmentSection.StrengthStabilityPointConstruction);
AddSections(assessmentSection.StrengthStabilityLengthwiseConstruction);
AddSections(assessmentSection.PipingStructure);
AddSections(assessmentSection.DuneErosion);
AddSections(assessmentSection.TechnicalInnovation);
return fullTestProject;
}
private static void AddSections(IFailureMechanism failureMechanism)
{
failureMechanism.AddSection(new FailureMechanismSection("section 1", new[]
{
new Point2D(0, 2),
new Point2D(2, 3)
}));
failureMechanism.AddSection(new FailureMechanismSection("section 2", new[]
{
new Point2D(2, 3),
new Point2D(4, 5)
}));
failureMechanism.AddSection(new FailureMechanismSection("section 3", new[]
{
new Point2D(4, 5),
new Point2D(2, 3)
}));
}
private static RingtoetsPipingSurfaceLine GetSurfaceLine()
{
var surfaceLine = new RingtoetsPipingSurfaceLine
{
Name = "Surfaceline",
ReferenceLineIntersectionWorldPoint = new Point2D(4.0, 6.0)
};
var geometryPoints = new[]
{
new Point3D(6.0, 6.0, -2.3),
new Point3D(5.8, 6.0, -2.3), // Dike toe at river
new Point3D(5.6, 6.0, 3.4),
new Point3D(4.2, 6.0, 3.5),
new Point3D(4.0, 6.0, 0.5), // Dike toe at polder
new Point3D(3.8, 6.0, 0.5), // Ditch dike side
new Point3D(3.6, 6.0, 0.2), // Bottom ditch dike side
new Point3D(3.4, 6.0, 0.25), // Bottom ditch polder side
new Point3D(3.2, 6.0, 0.5), // Ditch polder side
new Point3D(3.0, 6.0, 0.5),
};
surfaceLine.SetGeometry(geometryPoints);
surfaceLine.SetDikeToeAtRiverAt(geometryPoints[1]);
surfaceLine.SetDikeToeAtPolderAt(geometryPoints[4]);
surfaceLine.SetDitchDikeSideAt(geometryPoints[5]);
surfaceLine.SetBottomDitchDikeSideAt(geometryPoints[6]);
surfaceLine.SetBottomDitchPolderSideAt(geometryPoints[7]);
surfaceLine.SetDitchPolderSideAt(geometryPoints[8]);
return surfaceLine;
}
private static ReferenceLine GetReferenceLine()
{
IEnumerable points = new[]
{
new Point2D(2, 3),
new Point2D(5, 4),
new Point2D(5, 8),
new Point2D(-3, 2)
};
var referenceLine = new ReferenceLine();
referenceLine.SetGeometry(points);
return referenceLine;
}
private static HydraulicBoundaryDatabase GetHydraulicBoundaryDatabase()
{
var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
{
FilePath = "/temp/test",
Version = "1.0"
};
hydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(13001, "test", 152.3, 2938.5)
{
DesignWaterLevel = 12.4
});
return hydraulicBoundaryDatabase;
}
}
}