Index: src/Deltares.DSoilModel.Forms.Tests/SegmentControlTests.cs =================================================================== diff -u --- src/Deltares.DSoilModel.Forms.Tests/SegmentControlTests.cs (revision 0) +++ src/Deltares.DSoilModel.Forms.Tests/SegmentControlTests.cs (revision 386) @@ -0,0 +1,116 @@ +using System.Collections.Generic; +using System.Drawing; +using Deltares.DSoilModel.Data; +using Deltares.Geotechnics; +using Deltares.Geotechnics.ConePenetrationTest; +using Deltares.Geotechnics.Mechanisms; +using Deltares.Geotechnics.Xsd; +using Deltares.Standard.Forms; +using Deltares.Standard.TestUtils; +using NUnit.Framework; + +namespace Deltares.DSoilModel.Forms.Tests +{ + [TestFixture, RequiresSTA] + class SegmentControlTests : ControlTester + { + protected override IPropertyControl CreatePropertyControl() + { + return new SegmentControl(); + } + + private DSoilModelProject CreateProject() + { + var project = new DSoilModelProject(); + project.Soils = new SoilList(); + project.Soils.Add(new Soil("Soil1", Color.AliceBlue)); + project.Soils.Add(new Soil("Soil2", Color.AliceBlue)); + project.SurfaceLines.AddRange(new List { new SurfaceLine2 { Name = "SF1" }, new SurfaceLine2 { Name = "SF2" } }); + project.CPTs.AddRange(new List { new ConePenetrationTestData { CPTDatarows = { new CPTDatarow(), new CPTDatarow(), new CPTDatarow() } } }); + return project; + } + + private SoilSegment CreateSegment(DSoilModelProject project) + { + SoilSegment.GetCpts = (seg) => project.CPTs; + SoilSegment.GetBorings = (seg) => new List { new Boring(), new Boring() }; + SoilSegment.GetSurfaceLines = (seg) => new List { new SurfaceLine2(), new SurfaceLine2() }; + SoilSegment.DomainProvider = project; + var segment = new SoilSegment + { + Name = "SegmentName", + StochasticSoilModel = new StochasticSoilModel() + { + StochasticSoilProfiles = new List() { new StochasticSoilProfile(), new StochasticSoilProfile { Profile = new SoilProfile1D() } } + }, + DefaultFillMaterialName = project.Soils.Soils[1], + Mechanism = Mechanism.Stability, + SurfaceLine = project.SurfaceLines[1], + CreateSettlementZones = true + }; + segment.Cpts.AddRange(new[] { new ConePenetrationTestPerSegment { ConePenetrationTestData = project.CPTs[0] } }); + segment.Borings.AddRange(new[] { new BoringPerSegment { Boring = new Boring() } }); + return segment; + } + + [Test] + public void ControlBindingsTest() + { + var project = CreateProject(); + var segment = CreateSegment(project); + + PropertyControl.SelectedObject = segment; + + TestLabelControlVisibleValue(PropertyControl, "NameLabel", true, "Naam"); + TestTextEditVisibleEnabledValue(PropertyControl, "NameEdit", true, true, segment, s => s.Name, "Other remark"); + TestLabelControlVisibleValue(PropertyControl, "SurfaceLineLabel", true, "Hoogte dwarsprofiel"); +// TestComboBoxVisibleEnabledValue(PropertyControl, "SurfaceLineComboBox", true, true, segment, s => s.SurfaceLine, project.SurfaceLines[0]); // TODO: combo item is not picked + TestLabelControlVisibleValue(PropertyControl, "FillMaterialLabel", true, "Standaard opvul materiaal"); + TestComboBoxVisibleEnabledValue(PropertyControl, "FillMaterialComboBox", true, true, segment, s => s.DefaultFillMaterialName, project.Soils.Soils[0]); + + TestCheckEditVisibleEnabledValue(PropertyControl, "ZonesCheckEdit", true, false, segment, s => s.CreateSettlementZones, "Maak zone", false); + TestGridVisibleEnabledSize(PropertyControl, "GeometriesGridControl", true, true, 2, 2); + TestGridVisibleEnabledSize(PropertyControl, "CptsGridViewControl", true, true, 1, 2); + TestGridVisibleEnabledSize(PropertyControl, "BoringsGridViewControl", true, true, 1, 2); + } + + [Test] + public void TestSelectedObject_SoilSegment() + { + var soilSegment = new SoilSegment(); + + Assert.AreNotSame(soilSegment, PropertyControl.SelectedObject); + + PropertyControl.SelectedObject = soilSegment; + Assert.AreSame(soilSegment, PropertyControl.SelectedObject); + } + + private class SegmentWithSegment : IHasSoilSegment + { + public SegmentWithSegment(SoilSegment segment) + { + SoilSegment = segment; + } + public SoilSegment SoilSegment { get; private set; } + } + + [Test] + [Category(Categories.WorkInProgress)] // DSB-546 + public void TestSelectedObject_IHasSoilSegment() + { + var project = CreateProject(); + var segmentWithSegment = new SegmentWithSegment(CreateSegment(project)); + + Assert.AreNotSame(segmentWithSegment.SoilSegment, PropertyControl.SelectedObject); + + PropertyControl.SelectedObject = segmentWithSegment; + Assert.AreSame(segmentWithSegment.SoilSegment, PropertyControl.SelectedObject); + } + + [Test] + public void TestIsVisible_AlwaysTrue() + { + Assert.IsTrue(PropertyControl.IsVisible); + } + } +} Index: src/Deltares.DSoilModel.Forms.Tests/Deltares.DSoilModel.Forms.Tests.csproj =================================================================== diff -u -r384 -r386 --- src/Deltares.DSoilModel.Forms.Tests/Deltares.DSoilModel.Forms.Tests.csproj (.../Deltares.DSoilModel.Forms.Tests.csproj) (revision 384) +++ src/Deltares.DSoilModel.Forms.Tests/Deltares.DSoilModel.Forms.Tests.csproj (.../Deltares.DSoilModel.Forms.Tests.csproj) (revision 386) @@ -110,6 +110,7 @@ +