using Deltares.DSoilModel.Data; using Deltares.Geometry; using Deltares.Geotechnics; using Deltares.Geotechnics.ConePenetrationTest; using Deltares.Geotechnics.IO; using Deltares.Standard; using Deltares.Standard.Forms.DExpress; using NUnit.Framework; namespace Deltares.DSoilModel.Forms.Tests { [TestFixture] public class DSoilModelGeometryEditorTests { private DSoilModelGeometryEditor geometryEditor; [TestFixtureSetUp] public void SetUp() { About.IgnoreAssemblyErrors = true; geometryEditor = new DSoilModelGeometryEditor(new MainForm()); } [TestFixtureTearDown] public void TearDown() { geometryEditor = null; } private DSoilModelProject CreateProjectForSoilProfile2D(SoilProfile2D profile) { var p = new DSoilModelProject(); p.BoringLookup2Ds.Add(new BoringLookup2D {SoilProfile2D = profile}); p.CptLookup2Ds.Add(new ConePenetrationTestLookup2D {SoilProfile2D = profile}); p.SpecificMechanismPointLocations.Add(new SpecificMechanismPointLocation {SoilProfile2D = profile}); p.Soilprofile1DLookup2Ds.Add(new SoilProfile1DLookup2D {SoilProfile2D = profile}); return p; } private DSoilModelProject CreateProjectForSoilProfile1D(SoilProfile1D profile) { var p = new DSoilModelProject(); p.BoringLookup1Ds.Add(new BoringLookup1D { SoilProfile1D = profile }); p.CptLookup1Ds.Add(new ConePenetrationTestLookup1D { SoilProfile1D = profile }); return p; } private SoilProfile2D CreateSoilProfile2D() { var profile = new SoilProfile2D(); profile.CenterCrestLocation = 55; profile.Geometry.Points.Add(new GeometryPoint(1, 1, 1)); profile.PreconsolidationStresses.Add(new PreConsolidationStress()); profile.Surfaces.Add(new SoilLayer2D()); return profile; } private SoilProfile1D CreateSoilProfile1D() { var profile = new SoilProfile1D(); profile.Layers.Add(new SoilLayer1D()); profile.Layers.Add(new SoilLayer1D()); return profile; } [Test] public void ClearGeometryForSoilProfile1DTest() { var soilProfile1D = CreateSoilProfile1D(); geometryEditor.Project = CreateProjectForSoilProfile1D(soilProfile1D); geometryEditor.ClearGeometryForSoilProfile1D(soilProfile1D); Assert.IsEmpty(geometryEditor.Project.BoringLookup1Ds); Assert.IsEmpty(geometryEditor.Project.CptLookup1Ds); Assert.IsEmpty(soilProfile1D.Layers); } [Test] public void ClearGeometryForSoilProfile2DTest() { var soilProfile2D = CreateSoilProfile2D(); geometryEditor.Project = CreateProjectForSoilProfile2D(soilProfile2D); geometryEditor.ClearGeometryForSoilProfile2D(soilProfile2D); Assert.IsEmpty(geometryEditor.Project.BoringLookup2Ds); Assert.IsEmpty(geometryEditor.Project.CptLookup2Ds); Assert.IsEmpty(geometryEditor.Project.SpecificMechanismPointLocations); Assert.IsEmpty(geometryEditor.Project.Soilprofile1DLookup2Ds); Assert.IsNaN(soilProfile2D.CenterCrestLocation); Assert.IsEmpty(soilProfile2D.Geometry.Points); Assert.IsEmpty(soilProfile2D.PreconsolidationStresses); Assert.IsEmpty(soilProfile2D.Surfaces); } [TestCase(null)] [TestCase("")] [TestCase("Name")] public void IsEnabledTest_AlwaysTrue(string propertyName) { Assert.IsTrue(geometryEditor.IsEnabled(propertyName)); // always true } } }