Index: Core/Common/src/Core.Common.Util/EnumDisplayWrapper.cs =================================================================== diff -u -r6cdb90fc3f89fe0c44b62d3be7266a0090a6b891 -rdbe1fc48be00127a63be0d2c99d9232ae6b65b39 --- Core/Common/src/Core.Common.Util/EnumDisplayWrapper.cs (.../EnumDisplayWrapper.cs) (revision 6cdb90fc3f89fe0c44b62d3be7266a0090a6b891) +++ Core/Common/src/Core.Common.Util/EnumDisplayWrapper.cs (.../EnumDisplayWrapper.cs) (revision dbe1fc48be00127a63be0d2c99d9232ae6b65b39) @@ -68,6 +68,11 @@ /// if no was defined for the enum value. public string DisplayName { get; private set; } + public override string ToString() + { + return DisplayName; + } + private void SetDisplayName(T value) { DisplayName = new EnumTypeConverter(typeof(T)).ConvertToString(value) ?? value.ToString(); Index: Core/Common/test/Core.Common.Util.Test/EnumDisplayWrapperTest.cs =================================================================== diff -u -r51b64230b9b947ba32821ed104809429d469959b -rdbe1fc48be00127a63be0d2c99d9232ae6b65b39 --- Core/Common/test/Core.Common.Util.Test/EnumDisplayWrapperTest.cs (.../EnumDisplayWrapperTest.cs) (revision 51b64230b9b947ba32821ed104809429d469959b) +++ Core/Common/test/Core.Common.Util.Test/EnumDisplayWrapperTest.cs (.../EnumDisplayWrapperTest.cs) (revision dbe1fc48be00127a63be0d2c99d9232ae6b65b39) @@ -34,22 +34,22 @@ public void Constructor_WithoutValue_ThrowsArgumentNullException() { // Call - TestDelegate test = () => new EnumDisplayWrapper(null); + void Call() => new EnumDisplayWrapper(null); // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("value", paramName); + var exception = Assert.Throws(Call); + Assert.AreEqual("value", exception.ParamName); } [Test] public void Constructor_WithTypeParameterNotOfEnumType_ThrowsArgumentException() { // Call - TestDelegate test = () => new EnumDisplayWrapper(TestEnum.DisplayName); + void Call() => new EnumDisplayWrapper(TestEnum.DisplayName); // Assert - string paramName = Assert.Throws(test).TypeParamName; - Assert.AreEqual("T", paramName); + var exception = Assert.Throws(Call); + Assert.AreEqual("T", exception.TypeParamName); } [Test] @@ -79,6 +79,19 @@ Assert.AreEqual(Resources.EnumDisplayWrapperTest_DisplayNameValueDisplayName, displayName); } + [Test] + public void ToString_Always_SameAsDisplayName() + { + // Setup + var wrapper = new EnumDisplayWrapper(TestEnum.DisplayName); + + // Call + var toString = wrapper.ToString(); + + // Assert + Assert.AreEqual(wrapper.DisplayName, toString); + } + private enum TestEnum { NoDisplayName, Index: Riskeer/Common/test/Riskeer.Common.Data.TestUtil.Test/DikeProfileTestFactoryTest.cs =================================================================== diff -u -rc4311504aa83ba59c5a7e80c0e9bc26650986c05 -rdbe1fc48be00127a63be0d2c99d9232ae6b65b39 --- Riskeer/Common/test/Riskeer.Common.Data.TestUtil.Test/DikeProfileTestFactoryTest.cs (.../DikeProfileTestFactoryTest.cs) (revision c4311504aa83ba59c5a7e80c0e9bc26650986c05) +++ Riskeer/Common/test/Riskeer.Common.Data.TestUtil.Test/DikeProfileTestFactoryTest.cs (.../DikeProfileTestFactoryTest.cs) (revision dbe1fc48be00127a63be0d2c99d9232ae6b65b39) @@ -172,7 +172,33 @@ Assert.AreEqual(point, dikeProfile.WorldReferencePoint); Assert.AreEqual(0, dikeProfile.X0); } + + [Test] + public void CreateDikeProfile_WithIdAndNameAndPoint_ReturnsExpectedValues() + { + // Setup + const string id = "1"; + const string name = "N"; + var point = new Point2D(-12.34, 7.78); + // Call + DikeProfile dikeProfile = DikeProfileTestFactory.CreateDikeProfile(id, name, point); + + // Assert + Assert.IsNotNull(dikeProfile); + Assert.IsNotNull(dikeProfile.ForeshoreProfile); + Assert.IsNull(dikeProfile.BreakWater); + CollectionAssert.IsEmpty(dikeProfile.DikeGeometry); + Assert.AreEqual(0, dikeProfile.DikeHeight.Value); + CollectionAssert.IsEmpty(dikeProfile.ForeshoreGeometry); + Assert.IsFalse(dikeProfile.HasBreakWater); + Assert.AreEqual(id, dikeProfile.Id); + Assert.AreEqual(name, dikeProfile.Name); + Assert.AreEqual(0, dikeProfile.Orientation.Value); + Assert.AreEqual(point, dikeProfile.WorldReferencePoint); + Assert.AreEqual(0, dikeProfile.X0); + } + [Test] public void CreateDikeProfile_WithForeshoreGeometry_ReturnsExpectedValues() { Index: Riskeer/Common/test/Riskeer.Common.Data.TestUtil/DikeProfileTestFactory.cs =================================================================== diff -u -r88575e30eedb51a2776dcd1d40384b136fa8ea26 -rdbe1fc48be00127a63be0d2c99d9232ae6b65b39 --- Riskeer/Common/test/Riskeer.Common.Data.TestUtil/DikeProfileTestFactory.cs (.../DikeProfileTestFactory.cs) (revision 88575e30eedb51a2776dcd1d40384b136fa8ea26) +++ Riskeer/Common/test/Riskeer.Common.Data.TestUtil/DikeProfileTestFactory.cs (.../DikeProfileTestFactory.cs) (revision dbe1fc48be00127a63be0d2c99d9232ae6b65b39) @@ -131,6 +131,17 @@ } /// + /// Creates a default at the world location. + /// + /// The ID of the dike profile. + /// The name of the dike profile. + /// The world coordinate of the dike profile. + public static DikeProfile CreateDikeProfile(string id, string name, Point2D point) + { + return CreateDikeProfile(id, name, point, Enumerable.Empty(), Enumerable.Empty()); + } + + /// /// Creates a default at the world location with /// a specified foreshore profile geometry. /// Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsCalculationsViewTest.cs =================================================================== diff -u -r8dbe77c4864b019630360007c972593b2e91a753 -rdbe1fc48be00127a63be0d2c99d9232ae6b65b39 --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsCalculationsViewTest.cs (.../GrassCoverErosionInwardsCalculationsViewTest.cs) (revision 8dbe77c4864b019630360007c972593b2e91a753) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsCalculationsViewTest.cs (.../GrassCoverErosionInwardsCalculationsViewTest.cs) (revision dbe1fc48be00127a63be0d2c99d9232ae6b65b39) @@ -1,4 +1,4 @@ -// Copyright (C) Stichting Deltares 2019. All rights reserved. +// Copyright (C) Stichting Deltares 2019. All rights reserved. // // This file is part of Riskeer. // @@ -126,6 +126,50 @@ } [Test] + public void CalculationsView_FailureMechanismWithDikeProfiles_DikeProfilesComboboxCorrectlyInitialized() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + ShowFullyConfiguredCalculationsView(assessmentSection); + + // Assert + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; + var dikeProfileComboBox = (DataGridViewComboBoxColumn)dataGridView.Columns[dikeProfileColumnIndex]; + DataGridViewComboBoxCell.ObjectCollection dikeProfileComboBoxItems = dikeProfileComboBox.Items; + Assert.AreEqual(3, dikeProfileComboBoxItems.Count); + Assert.AreEqual("", dikeProfileComboBoxItems[0].ToString()); + Assert.AreEqual("Profiel 1", dikeProfileComboBoxItems[1].ToString()); + Assert.AreEqual("Profiel 2", dikeProfileComboBoxItems[2].ToString()); + mocks.VerifyAll(); + } + + [Test] + public void CalculationsView_Always_BreakWaterTypeComboboxCorrectlyInitialized() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + ShowFullyConfiguredCalculationsView(assessmentSection); + + // Assert + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; + var breakWaterTypeComboBox = (DataGridViewComboBoxColumn)dataGridView.Columns[breakWaterTypeColumnIndex]; + DataGridViewComboBoxCell.ObjectCollection breakWaterTypeComboBoxItems = breakWaterTypeComboBox.Items; + Assert.AreEqual(3, breakWaterTypeComboBoxItems.Count); + Assert.AreEqual("Muur", breakWaterTypeComboBoxItems[0].ToString()); + Assert.AreEqual("Caisson", breakWaterTypeComboBoxItems[1].ToString()); + Assert.AreEqual("Havendam", breakWaterTypeComboBoxItems[2].ToString()); + mocks.VerifyAll(); + } + + [Test] public void ButtonGenerateCalculations_DikeProfilesPresent_ButtonEnabled() { // Setup @@ -618,8 +662,8 @@ failureMechanism.DikeProfiles.AddRange(new List { - DikeProfileTestFactory.CreateDikeProfile(new Point2D(0.0, 0.0), "profiel 1"), - DikeProfileTestFactory.CreateDikeProfile(new Point2D(5.0, 0.0), "profiel 2") + DikeProfileTestFactory.CreateDikeProfile("1", "Profiel 1", new Point2D(0.0, 0.0)), + DikeProfileTestFactory.CreateDikeProfile("2", "Profiel 2", new Point2D(5.0, 0.0)) }, string.Empty); return failureMechanism;