Index: src/Deltares.DSoilModel.Forms.Tests/Deltares.DSoilModel.Forms.Tests.csproj
===================================================================
diff -u -r296 -r304
--- src/Deltares.DSoilModel.Forms.Tests/Deltares.DSoilModel.Forms.Tests.csproj (.../Deltares.DSoilModel.Forms.Tests.csproj) (revision 296)
+++ src/Deltares.DSoilModel.Forms.Tests/Deltares.DSoilModel.Forms.Tests.csproj (.../Deltares.DSoilModel.Forms.Tests.csproj) (revision 304)
@@ -60,7 +60,19 @@
False
..\..\lib\Deltares\DslFormsStandard\Deltares.Standard.Forms.DExpress.dll
+
+ False
+ ..\..\lib\DevExpress\DevExpress.Data.v12.2.dll
+
+
+ False
+ ..\..\lib\DevExpress\DevExpress.XtraEditors.v12.2.dll
+
+
+ False
+ ..\..\lib\DevExpress\DevExpress.XtraGrid.v12.2.dll
+
..\packages\NUnit.2.6.2\lib\nunit.framework.dll
True
@@ -80,6 +92,7 @@
+
Index: src/Deltares.DSoilModel.Forms.Tests/SosSoilProfile1DControlTest.cs
===================================================================
diff -u
--- src/Deltares.DSoilModel.Forms.Tests/SosSoilProfile1DControlTest.cs (revision 0)
+++ src/Deltares.DSoilModel.Forms.Tests/SosSoilProfile1DControlTest.cs (revision 304)
@@ -0,0 +1,129 @@
+using System.CodeDom;
+using System.Reflection;
+using Deltares.DSoilModel.Data;
+using Deltares.Standard.Forms.DExpress;
+using Deltares.Geotechnics;
+using DevExpress.XtraEditors;
+using NUnit.Framework;
+
+namespace Deltares.DSoilModel.Forms.Tests
+{
+ [TestFixture, RequiresSTA]
+ class SosSoilProfile1DControlTest
+ {
+ [Test]
+ public void TestControlBindings()
+ {
+ var oldBypass = BindSupport.BypassTimerForUnitTest;
+ BindSupport.BypassTimerForUnitTest = true;
+
+ try
+ {
+ using (var control = new SosSoilProfile1DControl())
+ {
+ var profile = new SoilProfile1D
+ {
+ Name = "Name",
+ ProbabilityOfOccurrence = 0.5,
+ X = 1.23,
+ Y = 2.34,
+ TopLevel = 0.123,
+ BottomLevel = -0.123,
+ Layers =
+ {
+ new SosSoilLayer1D(),
+ new SosSoilLayer1D()
+ }
+ };
+
+ control.SelectedObject = profile;
+
+ Assert.IsTrue(control.IsVisible);
+
+ var nameEdit = GetPrivateField(control, "NameEdit") as TextEdit;
+ Assert.IsTrue(nameEdit.Visible && nameEdit.Enabled);
+ Assert.AreEqual(profile.Name, nameEdit.EditValue);
+ nameEdit.EditValue = "NewName";
+ Assert.AreEqual(nameEdit.EditValue, profile.Name);
+
+ var probabilityEdit = GetPrivateField(control, "ProbabilityEdit") as SpinEdit;
+ Assert.IsTrue(probabilityEdit.Visible && probabilityEdit.Enabled);
+ Assert.AreEqual(profile.ProbabilityOfOccurrence, (double) probabilityEdit.Value);
+ probabilityEdit.EditValue = 1.0;
+ Assert.AreEqual((double) probabilityEdit.Value, profile.ProbabilityOfOccurrence);
+
+ var xEdit = GetPrivateField(control, "XEdit") as SpinEdit;
+ Assert.IsTrue(xEdit.Visible && xEdit.Enabled);
+ Assert.AreEqual(profile.X, (double) xEdit.Value);
+ xEdit.EditValue = 1.0;
+ Assert.AreEqual((double) xEdit.Value, profile.X);
+
+ var zEdit = GetPrivateField(control, "ZEdit") as SpinEdit;
+ Assert.IsTrue(zEdit.Visible && zEdit.Enabled);
+ Assert.AreEqual(profile.Y, (double) zEdit.Value);
+ zEdit.EditValue = 1.0;
+ Assert.AreEqual((double) zEdit.Value, profile.Y);
+
+ var topEdit = GetPrivateField(control, "TopEdit") as SpinEdit;
+ Assert.IsTrue(topEdit.Visible && topEdit.Enabled);
+ Assert.AreEqual(profile.TopLevel, (double) topEdit.Value);
+ topEdit.EditValue = 1.0;
+ Assert.AreEqual((double) topEdit.Value, profile.TopLevel);
+
+ var bottomEdit = GetPrivateField(control, "BottomEdit") as SpinEdit;
+ Assert.IsTrue(bottomEdit.Visible && bottomEdit.Enabled);
+ Assert.AreEqual(profile.BottomLevel, (double) bottomEdit.Value);
+ bottomEdit.EditValue = 1.0;
+ Assert.AreEqual((double) bottomEdit.Value, profile.BottomLevel);
+
+ var heightEdit = GetPrivateField(control, "HeightEdit") as SpinEdit;
+ Assert.IsTrue(heightEdit.Visible && !heightEdit.Enabled);
+ Assert.AreEqual(profile.Height, (double) heightEdit.Value);
+
+ var gridControl = GetPrivateField(control, "LayersGridControl") as GridViewControl;
+ Assert.IsTrue(gridControl.Visible && gridControl.Enabled);
+ Assert.AreEqual(2, gridControl.gridView1.RowCount);
+ Assert.AreEqual(10, gridControl.gridView1.Columns.Count);
+ }
+ }
+ finally
+ {
+ BindSupport.BypassTimerForUnitTest = oldBypass;
+ }
+ }
+
+ [Test]
+ public void TestSelectedObjectTypes()
+ {
+ // indirect assignment of a SoilProfile1D
+ using (var control = new SosSoilProfile1DControl())
+ {
+ var profile = new SoilProfile1D();
+ var ssp = new StochasticSoilProfile
+ {
+ Profile = profile
+ };
+ control.SelectedObject = ssp;
+ Assert.AreSame(profile, control.SelectedObject);
+
+ ssp.Profile = null;
+ control.SelectedObject = ssp;
+ Assert.IsNull(control.SelectedObject);
+
+ var layer = new SoilLayer1D
+ {
+ SoilProfile = profile
+ };
+ control.SelectedObject = layer;
+ Assert.AreSame(profile, control.SelectedObject);
+ }
+ }
+
+ private object GetPrivateField(object control, string field)
+ {
+ return control.GetType().GetField(field, BindingFlags.NonPublic | BindingFlags.Instance).GetValue(control);
+ }
+
+
+ }
+}