Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r070f77d4fa62658c40449c64eac12a85dc51ea41 -r23d7af54feb72aa59fa17acb00d29a16921f1b94
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 070f77d4fa62658c40449c64eac12a85dc51ea41)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -55,7 +55,7 @@
-
+
@@ -145,7 +145,7 @@
-
+
Fisheye: Tag 23d7af54feb72aa59fa17acb00d29a16921f1b94 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Create/FailureMechanismPlaceholderCreateExtensions.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StandAloneFailureMechanismCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StandAloneFailureMechanismCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StandAloneFailureMechanismCreateExtensions.cs (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -0,0 +1,60 @@
+// 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;
+using Application.Ringtoets.Storage.DbContext;
+using Ringtoets.Integration.Data.Placeholders;
+
+namespace Application.Ringtoets.Storage.Create
+{
+ ///
+ /// Extension methods for related to creating a .
+ ///
+ public static class StandAloneFailureMechanismCreateExtensions
+ {
+ ///
+ /// Creates a based on the information of the .
+ ///
+ /// The failure mechanism to create a database entity for.
+ /// The type of the failure mechanism that is being created.
+ /// The object keeping track of create operations.
+ /// A new .
+ /// Thrown when is null.
+ public static FailureMechanismEntity Create(this StandAloneFailureMechanism mechanism, FailureMechanismType type, CreateConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ FailureMechanismEntity entity = new FailureMechanismEntity
+ {
+ FailureMechanismType = (short)type,
+ IsRelevant = Convert.ToByte(mechanism.IsRelevant)
+ };
+
+ mechanism.CreateFailureMechanismSections(collector, entity);
+
+ collector.Create(entity, mechanism);
+ return entity;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntity.cs
===================================================================
diff -u -r7206def3cee84d518d3f7ea1b76e05e3163b8aea -r23d7af54feb72aa59fa17acb00d29a16921f1b94
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntity.cs (.../AssessmentSectionEntity.cs) (revision 7206def3cee84d518d3f7ea1b76e05e3163b8aea)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntity.cs (.../AssessmentSectionEntity.cs) (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -139,18 +139,18 @@
ReadFailureMechanismPlaceholder(FailureMechanismType.DuneErosion, assessmentSection.DuneErosion);
}
- private void ReadFailureMechanismPlaceholder(FailureMechanismType failureMechanismType, FailureMechanismPlaceholder failureMechanismPlaceholder)
+ private void ReadFailureMechanismPlaceholder(FailureMechanismType failureMechanismType, StandAloneFailureMechanism standAloneFailureMechanism)
{
var failureMechanismEntity = FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (int) failureMechanismType);
if (failureMechanismEntity != null)
{
var failureMechanism = failureMechanismEntity.ReadAsFailureMechanismPlaceholder();
- failureMechanismPlaceholder.StorageId = failureMechanism.StorageId;
- failureMechanismPlaceholder.IsRelevant = failureMechanism.IsRelevant;
+ standAloneFailureMechanism.StorageId = failureMechanism.StorageId;
+ standAloneFailureMechanism.IsRelevant = failureMechanism.IsRelevant;
foreach (var failureMechanismSection in failureMechanism.Sections)
{
- failureMechanismPlaceholder.AddSection(failureMechanismSection);
+ standAloneFailureMechanism.AddSection(failureMechanismSection);
}
}
}
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntity.cs
===================================================================
diff -u -r13fcf9943a26918929a3ada0363c2414480db077 -r23d7af54feb72aa59fa17acb00d29a16921f1b94
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntity.cs (.../FailureMechanismEntity.cs) (revision 13fcf9943a26918929a3ada0363c2414480db077)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntity.cs (.../FailureMechanismEntity.cs) (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -81,12 +81,12 @@
}
///
- /// Read the and use the information to construct a .
+ /// Read the and use the information to construct a .
///
- /// A new .
- public FailureMechanismPlaceholder ReadAsFailureMechanismPlaceholder()
+ /// A new .
+ public StandAloneFailureMechanism ReadAsFailureMechanismPlaceholder()
{
- var failureMechanism = new FailureMechanismPlaceholder("temporaryName", "temporaryCode")
+ var failureMechanism = new StandAloneFailureMechanism("temporaryName", "temporaryCode")
{
StorageId = FailureMechanismEntityId,
IsRelevant = IsRelevant == 1
Fisheye: Tag 23d7af54feb72aa59fa17acb00d29a16921f1b94 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Update/FailureMechanismPlaceholderUpdateExtensions.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StandAloneFailureMechanismUpdateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StandAloneFailureMechanismUpdateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StandAloneFailureMechanismUpdateExtensions.cs (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -0,0 +1,79 @@
+// 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;
+using System.Linq;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.Properties;
+using Ringtoets.Integration.Data.Placeholders;
+
+namespace Application.Ringtoets.Storage.Update
+{
+ ///
+ /// Extension methods for related to updating a .
+ ///
+ public static class StandAloneFailureMechanismUpdateExtensions
+ {
+ ///
+ /// Updates a in the database based on the information of the
+ /// .
+ ///
+ /// The mechanism to update the database entity for.
+ /// The object keeping track of update operations.
+ /// The context to obtain the existing entity from.
+ /// Thrown when either:
+ ///
+ /// is null
+ /// is null
+ ///
+ public static void Update(this StandAloneFailureMechanism mechanism, UpdateConversionCollector collector, IRingtoetsEntities context)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException("context");
+ }
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = GetSingleFailureMechanism(mechanism, context);
+ entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant);
+
+ mechanism.UpdateFailureMechanismSections(collector, entity, context);
+
+ collector.Update(entity);
+ }
+
+ private static FailureMechanismEntity GetSingleFailureMechanism(StandAloneFailureMechanism mechanism, IRingtoetsEntities context)
+ {
+ try
+ {
+ return context.FailureMechanismEntities.Single(fme => fme.FailureMechanismEntityId == mechanism.StorageId);
+ }
+ catch (InvalidOperationException exception)
+ {
+ throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(FailureMechanismEntity).Name, mechanism.StorageId), exception);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r070f77d4fa62658c40449c64eac12a85dc51ea41 -r23d7af54feb72aa59fa17acb00d29a16921f1b94
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 070f77d4fa62658c40449c64eac12a85dc51ea41)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -84,7 +84,7 @@
-
+
@@ -116,7 +116,7 @@
-
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/CreateConversionCollectorTest.cs
===================================================================
diff -u -r13fcf9943a26918929a3ada0363c2414480db077 -r23d7af54feb72aa59fa17acb00d29a16921f1b94
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/CreateConversionCollectorTest.cs (.../CreateConversionCollectorTest.cs) (revision 13fcf9943a26918929a3ada0363c2414480db077)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/CreateConversionCollectorTest.cs (.../CreateConversionCollectorTest.cs) (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -478,7 +478,7 @@
{
FailureMechanismEntityId = storageId
};
- var model = new FailureMechanismPlaceholder("name", "code");
+ var model = new StandAloneFailureMechanism("name", "code");
collector.Create(entity, model);
// Call
Fisheye: Tag 23d7af54feb72aa59fa17acb00d29a16921f1b94 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/FailureMechanismPlaceholderCreateExtensionsTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StandAloneFailureMechanismCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StandAloneFailureMechanismCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StandAloneFailureMechanismCreateExtensionsTest.cs (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -0,0 +1,92 @@
+// 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;
+using Application.Ringtoets.Storage.Create;
+using Application.Ringtoets.Storage.DbContext;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Integration.Data.Placeholders;
+
+namespace Application.Ringtoets.Storage.Test.Create
+{
+ [TestFixture]
+ public class StandAloneFailureMechanismCreateExtensionsTest
+ {
+ [Test]
+ public void Create_WithoutCollector_ThrowsArgumentNullException()
+ {
+ // Setup
+ var failureMechanism = new StandAloneFailureMechanism("name", "code");
+
+ // Call
+ TestDelegate test = () => failureMechanism.Create(FailureMechanismType.DuneErosion, null);
+
+ // Assert
+ var parameterName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", parameterName);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Create_WithCollector_ReturnsFailureMechanismEntityWithPropertiesSet(bool isRelevant)
+ {
+ // Setup
+ var failureMechanism = new StandAloneFailureMechanism("name", "code")
+ {
+ IsRelevant = isRelevant
+ };
+ var collector = new CreateConversionCollector();
+ var failureMechanismType = FailureMechanismType.DuneErosion;
+
+ // Call
+ var entity = failureMechanism.Create(failureMechanismType, collector);
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual((short)failureMechanismType, entity.FailureMechanismType);
+ Assert.AreEqual(Convert.ToByte(isRelevant), entity.IsRelevant);
+ Assert.IsEmpty(entity.StochasticSoilModelEntities);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Create_WithSections_ReturnsFailureMechanismEntityWithFailureMechanismSectionEntities(bool isRelevant)
+ {
+ // Setup
+ var failureMechanism = new StandAloneFailureMechanism("name", "code");
+ failureMechanism.AddSection(new FailureMechanismSection(string.Empty, new[] { new Point2D(0, 0) }));
+ failureMechanism.AddSection(new FailureMechanismSection(string.Empty, new[] { new Point2D(0, 0) }));
+ var collector = new CreateConversionCollector();
+ var failureMechanismType = FailureMechanismType.DuneErosion;
+
+ // Call
+ var entity = failureMechanism.Create(failureMechanismType, collector);
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual(2, entity.FailureMechanismSectionEntities.Count);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 23d7af54feb72aa59fa17acb00d29a16921f1b94 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/FailureMechanismPlaceholderUpdateExtensionsTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/StandAloneFailureMechanismUpdateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/StandAloneFailureMechanismUpdateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/StandAloneFailureMechanismUpdateExtensionsTest.cs (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -0,0 +1,234 @@
+// 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;
+using System.Linq;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.TestUtil;
+using Application.Ringtoets.Storage.Update;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Integration.Data.Placeholders;
+
+namespace Application.Ringtoets.Storage.Test.Update
+{
+ [TestFixture]
+ public class StandAloneFailureMechanismUpdateExtensionsTest
+ {
+
+ [Test]
+ public void Update_WithoutContext_ArgumentNullException()
+ {
+ // Setup
+ var failureMechanism = new StandAloneFailureMechanism("name", "code");
+
+ // Call
+ TestDelegate test = () => failureMechanism.Update(new UpdateConversionCollector(), null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("context", paramName);
+ }
+
+ [Test]
+ public void Update_WithoutCollector_ArgumentNullException()
+ {
+ // Setup
+ var failureMechanism = new StandAloneFailureMechanism("name", "code");
+
+ // Call
+ TestDelegate test = () =>
+ {
+ using (var ringtoetsEntities = new RingtoetsEntities())
+ {
+ failureMechanism.Update(null, ringtoetsEntities);
+ }
+ };
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", paramName);
+ }
+
+ [Test]
+ public void Update_ContextWithNoFailureMechanism_EntityNotFoundException()
+ {
+ // Setup
+ var failureMechanism = new StandAloneFailureMechanism("name", "code");
+
+ // Call
+ TestDelegate test = () =>
+ {
+ using (var ringtoetsEntities = new RingtoetsEntities())
+ {
+ failureMechanism.Update(new UpdateConversionCollector(), ringtoetsEntities);
+ }
+ };
+
+ // Assert
+ var expectedMessage = String.Format("Het object 'FailureMechanismEntity' met id '{0}' is niet gevonden.", 0);
+ EntityNotFoundException exception = Assert.Throws(test);
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+
+ [Test]
+ public void Update_ContextWithNoFailureMechanismWithId_EntityNotFoundException()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var storageId = 1;
+ var failureMechanism = new StandAloneFailureMechanism("name", "code")
+ {
+ StorageId = storageId
+ };
+
+ ringtoetsEntities.FailureMechanismEntities.Add(new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 2
+ });
+
+ // Call
+ TestDelegate test = () => failureMechanism.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ var expectedMessage = String.Format("Het object 'FailureMechanismEntity' met id '{0}' is niet gevonden.", storageId);
+ EntityNotFoundException exception = Assert.Throws(test);
+ Assert.AreEqual(expectedMessage, exception.Message);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_ContextWithFailureMechanism_PropertiesUpdated()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var failureMechanism = new StandAloneFailureMechanism("name", "code")
+ {
+ StorageId = 1,
+ IsRelevant = true
+ };
+
+ var failureMechanismEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 1,
+ IsRelevant = Convert.ToByte(false)
+ };
+
+ ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity);
+
+ // Call
+ failureMechanism.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(Convert.ToByte(true), failureMechanismEntity.IsRelevant);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_ContextWithNewFailureMechanismSections_FailureMechanismSectionsAdded()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var failureMechanism = new StandAloneFailureMechanism("name", "code")
+ {
+ StorageId = 1
+ };
+ failureMechanism.AddSection(new FailureMechanismSection("", new[] { new Point2D(0, 0) }));
+
+ var failureMechanismEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 1,
+ };
+
+ ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity);
+
+ // Call
+ failureMechanism.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.Count);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_ContextWithUpdatedFailureMechanismSections_NoNewFailureMechanismSectionsAdded()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var failureMechanism = new StandAloneFailureMechanism("name", "code")
+ {
+ StorageId = 1
+ };
+ var testName = "testName";
+ failureMechanism.AddSection(new FailureMechanismSection(testName, new[] { new Point2D(0, 0) })
+ {
+ StorageId = 1
+ });
+
+ var failureMechanismSectionEntity = new FailureMechanismSectionEntity
+ {
+ FailureMechanismSectionEntityId = 1,
+ };
+ var failureMechanismEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 1,
+ FailureMechanismSectionEntities =
+ {
+ failureMechanismSectionEntity
+ }
+ };
+
+ ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity);
+ ringtoetsEntities.FailureMechanismSectionEntities.Add(failureMechanismSectionEntity);
+
+ // Call
+ failureMechanism.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(1, failureMechanismEntity.FailureMechanismSectionEntities.Count);
+ Assert.AreEqual(testName, failureMechanismEntity.FailureMechanismSectionEntities.ElementAt(0).Name);
+
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/AssessmentSection.cs
===================================================================
diff -u -r13fcf9943a26918929a3ada0363c2414480db077 -r23d7af54feb72aa59fa17acb00d29a16921f1b94
--- Ringtoets/Integration/src/Ringtoets.Integration.Data/AssessmentSection.cs (.../AssessmentSection.cs) (revision 13fcf9943a26918929a3ada0363c2414480db077)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Data/AssessmentSection.cs (.../AssessmentSection.cs) (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -55,16 +55,16 @@
PipingFailureMechanism = new PipingFailureMechanism();
GrassCoverErosionInwards = new GrassCoverErosionInwardsFailureMechanism();
- MacrostabilityInwards = new FailureMechanismPlaceholder(Resources.MacrostabilityInwardFailureMechanism_DisplayName, Resources.MacrostabilityInwardFailureMechanism_Code);
- StabilityStoneCover = new FailureMechanismPlaceholder(Resources.StabilityStoneCoverFailureMechanism_DisplayName, Resources.StabilityStoneCoverFailureMechanism_Code);
- WaveImpactAsphaltCover = new FailureMechanismPlaceholder(Resources.WaveImpactAsphaltCoverFailureMechanism_DisplayName, Resources.WaveImpactAsphaltCoverFailureMechanism_Code);
- GrassCoverErosionOutside = new FailureMechanismPlaceholder(Resources.GrassCoverErosionOutsideFailureMechanism_DisplayName, Resources.GrassCoverErosionOutsideFailureMechanism_Code);
- GrassCoverSlipOffOutside = new FailureMechanismPlaceholder(Resources.GrassCoverSlipOffOutsideFailureMechanism_DisplayName, Resources.GrassCoverSlipOffOutsideFailureMechanism_Code);
- HeightStructure = new FailureMechanismPlaceholder(Resources.HeightStructureFailureMechanism_DisplayName, Resources.HeightStructureFailureMechanism_Code);
- ClosingStructure = new FailureMechanismPlaceholder(Resources.ClosingStructureFailureMechanism_DisplayName, Resources.ClosingStructureFailureMechanism_Code);
- StrengthStabilityPointConstruction = new FailureMechanismPlaceholder(Resources.StrengthStabilityPointConstructionFailureMechanism_DisplayName, Resources.StrengthStabilityPointConstructionFailureMechanism_Code);
- PipingStructure = new FailureMechanismPlaceholder(Resources.PipingStructureFailureMechanism_DisplayName, Resources.PipingStructureFailureMechanism_Code);
- DuneErosion = new FailureMechanismPlaceholder(Resources.DuneErosionFailureMechanism_DisplayName, Resources.DuneErosionFailureMechanism_Code);
+ MacrostabilityInwards = new StandAloneFailureMechanism(Resources.MacrostabilityInwardFailureMechanism_DisplayName, Resources.MacrostabilityInwardFailureMechanism_Code);
+ StabilityStoneCover = new StandAloneFailureMechanism(Resources.StabilityStoneCoverFailureMechanism_DisplayName, Resources.StabilityStoneCoverFailureMechanism_Code);
+ WaveImpactAsphaltCover = new StandAloneFailureMechanism(Resources.WaveImpactAsphaltCoverFailureMechanism_DisplayName, Resources.WaveImpactAsphaltCoverFailureMechanism_Code);
+ GrassCoverErosionOutside = new StandAloneFailureMechanism(Resources.GrassCoverErosionOutsideFailureMechanism_DisplayName, Resources.GrassCoverErosionOutsideFailureMechanism_Code);
+ GrassCoverSlipOffOutside = new StandAloneFailureMechanism(Resources.GrassCoverSlipOffOutsideFailureMechanism_DisplayName, Resources.GrassCoverSlipOffOutsideFailureMechanism_Code);
+ HeightStructure = new StandAloneFailureMechanism(Resources.HeightStructureFailureMechanism_DisplayName, Resources.HeightStructureFailureMechanism_Code);
+ ClosingStructure = new StandAloneFailureMechanism(Resources.ClosingStructureFailureMechanism_DisplayName, Resources.ClosingStructureFailureMechanism_Code);
+ StrengthStabilityPointConstruction = new StandAloneFailureMechanism(Resources.StrengthStabilityPointConstructionFailureMechanism_DisplayName, Resources.StrengthStabilityPointConstructionFailureMechanism_Code);
+ PipingStructure = new StandAloneFailureMechanism(Resources.PipingStructureFailureMechanism_DisplayName, Resources.PipingStructureFailureMechanism_Code);
+ DuneErosion = new StandAloneFailureMechanism(Resources.DuneErosionFailureMechanism_DisplayName, Resources.DuneErosionFailureMechanism_Code);
FailureMechanismContribution = new FailureMechanismContribution(GetFailureMechanisms(), 30, 30000);
ChangeComposition(composition);
@@ -83,52 +83,52 @@
///
/// Gets the "Dijken en dammen - Macrostabiliteit binnenwaarts" failure mechanism.
///
- public FailureMechanismPlaceholder MacrostabilityInwards { get; private set; }
+ public StandAloneFailureMechanism MacrostabilityInwards { get; private set; }
///
/// Gets the "Dijken en dammen - Stabiliteit steenzetting" failure mechanism.
///
- public FailureMechanismPlaceholder StabilityStoneCover { get; private set; }
+ public StandAloneFailureMechanism StabilityStoneCover { get; private set; }
///
/// Gets the "Dijken en dammen - Golfklappen op asfaltbekledingen" failure mechanism.
///
- public FailureMechanismPlaceholder WaveImpactAsphaltCover { get; private set; }
+ public StandAloneFailureMechanism WaveImpactAsphaltCover { get; private set; }
///
/// Gets the "Dijken en dammen - Grasbekleding erosie buitentalud" failure mechanism.
///
- public FailureMechanismPlaceholder GrassCoverErosionOutside { get; private set; }
+ public StandAloneFailureMechanism GrassCoverErosionOutside { get; private set; }
///
/// Gets the "Dijken en dammen - Grasbekleding afschuiven buitentalud" failure mechanism.
///
- public FailureMechanismPlaceholder GrassCoverSlipOffOutside { get; set; }
+ public StandAloneFailureMechanism GrassCoverSlipOffOutside { get; set; }
///
/// Gets the "Kunstwerken - Hoogte kunstwerk" failure mechanism.
///
- public FailureMechanismPlaceholder HeightStructure { get; private set; }
+ public StandAloneFailureMechanism HeightStructure { get; private set; }
///
/// Gets the "Kunstwerken - Betrouwbaarheid sluiting kunstwerk" failure mechanism.
///
- public FailureMechanismPlaceholder ClosingStructure { get; private set; }
+ public StandAloneFailureMechanism ClosingStructure { get; private set; }
///
/// Gets the "Kunstwerken - Piping bij kunstwerk" failure mechanism.
///
- public FailureMechanismPlaceholder PipingStructure { get; set; }
+ public StandAloneFailureMechanism PipingStructure { get; set; }
///
/// Gets the "Kunstwerken - Sterkte en stabiliteit puntconstructies" failure mechanism.
///
- public FailureMechanismPlaceholder StrengthStabilityPointConstruction { get; private set; }
+ public StandAloneFailureMechanism StrengthStabilityPointConstruction { get; private set; }
///
/// Gets the "Duinwaterkering - Duinafslag" failure mechanism.
///
- public FailureMechanismPlaceholder DuneErosion { get; private set; }
+ public StandAloneFailureMechanism DuneErosion { get; private set; }
public string Name { get; set; }
Fisheye: Tag 23d7af54feb72aa59fa17acb00d29a16921f1b94 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Data/Placeholders/FailureMechanismPlaceholder.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Placeholders/StandAloneFailureMechanism.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Data/Placeholders/StandAloneFailureMechanism.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Placeholders/StandAloneFailureMechanism.cs (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -0,0 +1,78 @@
+// 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;
+using System.Collections.Generic;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Placeholder;
+using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources;
+
+namespace Ringtoets.Integration.Data.Placeholders
+{
+ ///
+ /// Defines a placeholder for unimplemented failure mechanisms objects
+ ///
+ public class StandAloneFailureMechanism : FailureMechanismBase
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The name for the placeholder.
+ /// The code for the placeholder.
+ /// Thrown when either:
+ ///
+ /// is null or empty.
+ /// is null or empty.
+ ///
+ ///
+ public StandAloneFailureMechanism(string name, string code)
+ : base(name, code)
+ {
+ Locations = new InputPlaceholder(RingtoetsCommonDataResources.FailureMechanism_Locations_DisplayName);
+ BoundaryConditions = new InputPlaceholder(RingtoetsCommonDataResources.FailureMechanism_BoundaryConditions_DisplayName);
+ AssessmentResult = new OutputPlaceholder(RingtoetsCommonDataResources.FailureMechanism_AssessmentResult_DisplayName);
+ }
+
+ public override IEnumerable Calculations
+ {
+ get
+ {
+ yield break;
+ }
+ }
+
+ ///
+ /// Gets the locations relevant for evaluating this failure mechanism.
+ ///
+ public InputPlaceholder Locations { get; private set; }
+
+ ///
+ /// Gets the boundary conditions applying to this failure mechanism.
+ ///
+ public InputPlaceholder BoundaryConditions { get; private set; }
+
+ ///
+ /// Gets the calculation results for this failure mechanism.
+ ///
+ public OutputPlaceholder AssessmentResult { get; private set; }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj
===================================================================
diff -u -rb28f56d6bb3f14141bd003dd43378f8002a9e87a -r23d7af54feb72aa59fa17acb00d29a16921f1b94
--- Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj (.../Ringtoets.Integration.Data.csproj) (revision b28f56d6bb3f14141bd003dd43378f8002a9e87a)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj (.../Ringtoets.Integration.Data.csproj) (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -41,7 +41,7 @@
Properties\GlobalAssembly.cs
-
+ True
Fisheye: Tag 23d7af54feb72aa59fa17acb00d29a16921f1b94 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/FailureMechanismPlaceholderContext.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/StandAloneFailureMechanismContext.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/StandAloneFailureMechanismContext.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/StandAloneFailureMechanismContext.cs (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -0,0 +1,46 @@
+// 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;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Integration.Data.Placeholders;
+
+namespace Ringtoets.Integration.Forms.PresentationObjects
+{
+ ///
+ /// This class is a presentation object for an instance of .
+ ///
+ public class StandAloneFailureMechanismContext : FailureMechanismContext
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The failure mechanism.
+ /// The parent of .
+ /// Thrown when or are null.
+ public StandAloneFailureMechanismContext(StandAloneFailureMechanism wrappedFailureMechanism, IAssessmentSection parent) :
+ base(wrappedFailureMechanism, parent)
+ {
+
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 23d7af54feb72aa59fa17acb00d29a16921f1b94 refers to a dead (removed) revision in file `Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/FailureMechanismPlaceholderContextProperties.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/StandAloneFailureMechanismContextProperties.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/StandAloneFailureMechanismContextProperties.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/StandAloneFailureMechanismContextProperties.cs (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -0,0 +1,41 @@
+using Core.Common.Gui.Attributes;
+using Core.Common.Gui.PropertyBag;
+using Core.Common.Utils.Attributes;
+using Ringtoets.Integration.Forms.PresentationObjects;
+
+namespace Ringtoets.Integration.Forms.PropertyClasses
+{
+ ///
+ /// ViewModel of properties panel.
+ ///
+ public class StandAloneFailureMechanismContextProperties : ObjectProperties {
+
+ #region General
+
+ [PropertyOrder(1)]
+ [ResourcesCategory(typeof(Common.Data.Properties.Resources), "Categories_General")]
+ [ResourcesDisplayName(typeof(Common.Data.Properties.Resources), "FailureMechanism_Name_DisplayName")]
+ [ResourcesDescription(typeof(Common.Data.Properties.Resources), "FailureMechanism_Name_Description")]
+ public string Name
+ {
+ get
+ {
+ return data.WrappedData.Name;
+ }
+ }
+
+ [PropertyOrder(2)]
+ [ResourcesCategory(typeof(Common.Data.Properties.Resources), "Categories_General")]
+ [ResourcesDisplayName(typeof(Common.Data.Properties.Resources), "FailureMechanism_Code_DisplayName")]
+ [ResourcesDescription(typeof(Common.Data.Properties.Resources), "FailureMechanism_Code_Description")]
+ public string Code
+ {
+ get
+ {
+ return data.WrappedData.Code;
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj
===================================================================
diff -u -r4c81f998de5bd6df7e7c3119f75e1dd37c09ee2e -r23d7af54feb72aa59fa17acb00d29a16921f1b94
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 4c81f998de5bd6df7e7c3119f75e1dd37c09ee2e)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -45,9 +45,9 @@
Properties\GlobalAssembly.cs
-
+
-
+
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs
===================================================================
diff -u -r4c81f998de5bd6df7e7c3119f75e1dd37c09ee2e -r23d7af54feb72aa59fa17acb00d29a16921f1b94
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 4c81f998de5bd6df7e7c3119f75e1dd37c09ee2e)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -105,7 +105,7 @@
{
yield return new PropertyInfo();
yield return new PropertyInfo();
- yield return new PropertyInfo();
+ yield return new PropertyInfo();
}
///
@@ -193,7 +193,7 @@
Gui.Get(nodeData, treeViewControl).AddImportItem().Build()
};
- yield return RingtoetsTreeNodeInfoFactory.CreateFailureMechanismContextTreeNodeInfo(
+ yield return RingtoetsTreeNodeInfoFactory.CreateFailureMechanismContextTreeNodeInfo(
FailureMechanismPlaceholderEnabledChildNodeObjects,
FailureMechanismPlaceholderDisabledChildNodeObjects,
FailureMechanismPlaceholderEnabledContextMenuStrip,
@@ -413,12 +413,12 @@
{
foreach (IFailureMechanism failureMechanism in nodeData.GetFailureMechanisms())
{
- var placeHolder = failureMechanism as FailureMechanismPlaceholder;
+ var placeHolder = failureMechanism as StandAloneFailureMechanism;
var piping = failureMechanism as PipingFailureMechanism;
var grassCoverErosionInwards = failureMechanism as GrassCoverErosionInwardsFailureMechanism;
if (placeHolder != null)
{
- yield return new FailureMechanismPlaceholderContext(placeHolder, nodeData);
+ yield return new StandAloneFailureMechanismContext(placeHolder, nodeData);
}
else if (piping != null)
{
@@ -471,7 +471,7 @@
# region FailureMechanismPlaceHolderContext
- private object[] FailureMechanismPlaceholderEnabledChildNodeObjects(FailureMechanismPlaceholderContext nodeData)
+ private object[] FailureMechanismPlaceholderEnabledChildNodeObjects(StandAloneFailureMechanismContext nodeData)
{
return new object[]
{
@@ -484,15 +484,15 @@
};
}
- private object[] FailureMechanismPlaceholderDisabledChildNodeObjects(FailureMechanismPlaceholderContext nodeData)
+ private object[] FailureMechanismPlaceholderDisabledChildNodeObjects(StandAloneFailureMechanismContext nodeData)
{
return new object[]
{
new CommentContext(nodeData.WrappedData)
};
}
- private IList GetInputs(FailureMechanismPlaceholder nodeData, IAssessmentSection assessmentSection)
+ private IList GetInputs(StandAloneFailureMechanism nodeData, IAssessmentSection assessmentSection)
{
return new ArrayList
{
@@ -503,15 +503,15 @@
};
}
- private IList GetOutputs(FailureMechanismPlaceholder nodeData)
+ private IList GetOutputs(StandAloneFailureMechanism nodeData)
{
return new ArrayList
{
new FailureMechanismSectionResultContext(nodeData.SectionResults, nodeData)
};
}
- private ContextMenuStrip FailureMechanismPlaceholderEnabledContextMenuStrip(FailureMechanismPlaceholderContext nodeData, object parentData, TreeViewControl treeViewControl)
+ private ContextMenuStrip FailureMechanismPlaceholderEnabledContextMenuStrip(StandAloneFailureMechanismContext nodeData, object parentData, TreeViewControl treeViewControl)
{
var changeRelevancyItem = new StrictContextMenuItem(
RingtoetsCommonFormsResources.FailureMechanismContextMenuStrip_Is_relevant,
@@ -558,7 +558,7 @@
.Build();
}
- private ContextMenuStrip FailureMechanismPlaceholderDisabledContextMenuStrip(FailureMechanismPlaceholderContext nodeData, object parentData, TreeViewControl treeViewControl)
+ private ContextMenuStrip FailureMechanismPlaceholderDisabledContextMenuStrip(StandAloneFailureMechanismContext nodeData, object parentData, TreeViewControl treeViewControl)
{
var builder = Gui.Get(nodeData, treeViewControl);
Fisheye: Tag 23d7af54feb72aa59fa17acb00d29a16921f1b94 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Placeholders/FailureMechanismPlaceholderTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Placeholders/StandAloneFailureMechanismTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Placeholders/StandAloneFailureMechanismTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Placeholders/StandAloneFailureMechanismTest.cs (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -0,0 +1,78 @@
+// 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;
+using NUnit.Framework;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Integration.Data.Placeholders;
+
+namespace Ringtoets.Integration.Data.Test.Placeholders
+{
+ [TestFixture]
+ public class StandAloneFailureMechanismTest
+ {
+ [Test]
+ [TestCase("")]
+ [TestCase(null)]
+ public void Constructor_NullOrEmptyName_ThrowsArgumentException(string name)
+ {
+ // Call
+ TestDelegate test = () => new StandAloneFailureMechanism(name, "testCode");
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("failureMechanismName", paramName);
+ }
+
+ [Test]
+ [TestCase("")]
+ [TestCase(null)]
+ public void Constructor_NullOrEmptyCode_ThrowsArgumentException(string code)
+ {
+ // Call
+ TestDelegate test = () => new StandAloneFailureMechanism("testName", code);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("failureMechanismCode", paramName);
+ }
+
+ [Test]
+ public void Constructor_WithNameAndCode_PropertiesSet()
+ {
+ // Setup
+ const string expectedName = "testName";
+ const string expectedCode = "testCode";
+
+ // Call
+ var failureMechanism = new StandAloneFailureMechanism(expectedName, expectedCode);
+
+ // Assert
+ Assert.IsInstanceOf(failureMechanism);
+ Assert.AreEqual(expectedName, failureMechanism.Name);
+ Assert.AreEqual(expectedCode, failureMechanism.Code);
+ CollectionAssert.IsEmpty(failureMechanism.Sections);
+ Assert.AreEqual("Locaties", failureMechanism.Locations.Name);
+ Assert.AreEqual("Randvoorwaarden", failureMechanism.BoundaryConditions.Name);
+ Assert.AreEqual("Oordeel", failureMechanism.AssessmentResult.Name);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj
===================================================================
diff -u -rb28f56d6bb3f14141bd003dd43378f8002a9e87a -r23d7af54feb72aa59fa17acb00d29a16921f1b94
--- Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj (.../Ringtoets.Integration.Data.Test.csproj) (revision b28f56d6bb3f14141bd003dd43378f8002a9e87a)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Data.Test/Ringtoets.Integration.Data.Test.csproj (.../Ringtoets.Integration.Data.Test.csproj) (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -53,7 +53,7 @@
-
+
Fisheye: Tag 23d7af54feb72aa59fa17acb00d29a16921f1b94 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/FailureMechanismPlaceholderContextTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/StandAloneFailureMechanismContextTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/StandAloneFailureMechanismContextTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/StandAloneFailureMechanismContextTest.cs (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -0,0 +1,54 @@
+// 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 NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Integration.Data.Placeholders;
+using Ringtoets.Integration.Forms.PresentationObjects;
+
+namespace Ringtoets.Integration.Forms.Test.PresentationObjects
+{
+ [TestFixture]
+ public class StandAloneFailureMechanismContextTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StandAloneFailureMechanism("A", "C");
+
+ // Call
+ var context = new StandAloneFailureMechanismContext(failureMechanism, assessmentSection);
+
+ // Assert
+ Assert.IsInstanceOf>(context);
+ Assert.AreSame(failureMechanism, context.WrappedData);
+ Assert.AreSame(assessmentSection, context.Parent);
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 23d7af54feb72aa59fa17acb00d29a16921f1b94 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismPlaceholderContextPropertiesTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/StandAloneFailureMechanismContextPropertiesTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/StandAloneFailureMechanismContextPropertiesTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/StandAloneFailureMechanismContextPropertiesTest.cs (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -0,0 +1,41 @@
+using Core.Common.Gui.PropertyBag;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Integration.Data.Placeholders;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using Ringtoets.Integration.Forms.PropertyClasses;
+
+namespace Ringtoets.Integration.Forms.Test.PropertyClasses
+{
+ [TestFixture]
+ public class StandAloneFailureMechanismContextPropertiesTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+
+ // Call
+ var properties = new StandAloneFailureMechanismContextProperties();
+
+ // Assert
+ Assert.IsInstanceOf>(properties);
+ }
+
+ [Test]
+ public void Data_SetNewPipingFailureMechanismContextInstance_ReturnCorrectPropertyValues()
+ {
+ // Setup
+ var failureMechanism = new StandAloneFailureMechanism("testName", "testCode");
+ var properties = new StandAloneFailureMechanismContextProperties();
+
+ // Call
+ properties.Data = new StandAloneFailureMechanismContext(failureMechanism, new MockRepository().StrictMock());
+
+ // Assert
+ Assert.AreEqual(failureMechanism.Name, properties.Name);
+ Assert.AreEqual(failureMechanism.Code, properties.Code);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj
===================================================================
diff -u -r4c81f998de5bd6df7e7c3119f75e1dd37c09ee2e -r23d7af54feb72aa59fa17acb00d29a16921f1b94
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 4c81f998de5bd6df7e7c3119f75e1dd37c09ee2e)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -59,16 +59,16 @@
-
+
-
+
-
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs
===================================================================
diff -u -r13fcf9943a26918929a3ada0363c2414480db077 -r23d7af54feb72aa59fa17acb00d29a16921f1b94
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision 13fcf9943a26918929a3ada0363c2414480db077)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -142,7 +142,7 @@
var failureMechanisms = new IFailureMechanism[]
{
new PipingFailureMechanism(),
- new FailureMechanismPlaceholder("A", "C")
+ new StandAloneFailureMechanism("A", "C")
};
var contribution = new FailureMechanismContribution(failureMechanisms, 10.0, 2);
@@ -178,7 +178,7 @@
Assert.AreSame(failureMechanisms[0], pipingFailureMechanismContext.WrappedData);
Assert.AreSame(assessmentSection, pipingFailureMechanismContext.Parent);
- var placeholderFailureMechanismContext = (FailureMechanismPlaceholderContext) objects[5];
+ var placeholderFailureMechanismContext = (StandAloneFailureMechanismContext) objects[5];
Assert.AreSame(failureMechanisms[1], placeholderFailureMechanismContext.WrappedData);
Assert.AreSame(assessmentSection, placeholderFailureMechanismContext.Parent);
}
Fisheye: Tag 23d7af54feb72aa59fa17acb00d29a16921f1b94 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/FailureMechanismPlaceholderTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/StandAloneFailureMechanismTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/StandAloneFailureMechanismTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/StandAloneFailureMechanismTreeNodeInfoTest.cs (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -0,0 +1,464 @@
+// 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.Drawing;
+using System.Linq;
+
+using Core.Common.Base;
+using Core.Common.Base.Geometry;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.Commands;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.Gui.TestUtil.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Integration.Data.Placeholders;
+using Ringtoets.Integration.Forms.PresentationObjects;
+using Ringtoets.Integration.Plugin;
+using RingtoetsFormsResources = Ringtoets.Integration.Forms.Properties.Resources;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Forms.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class StandAloneFailureMechanismTreeNodeInfoTest
+ {
+ private MockRepository mocks;
+ private const int contextMenuRelevancyIndex = 0;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ using (var plugin = new RingtoetsGuiPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Assert
+ Assert.AreEqual(typeof(StandAloneFailureMechanismContext), info.TagType);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var testName = "ttt";
+ var placeholder = new StandAloneFailureMechanism(testName, "C");
+ var placeholderContext = new StandAloneFailureMechanismContext(placeholder, assessmentSection);
+
+ using (var plugin = new RingtoetsGuiPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var text = info.Text(placeholderContext);
+
+ // Assert
+ Assert.AreEqual(testName, text);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Image_Always_ReturnsSetImage()
+ {
+ // Setup
+ using (var plugin = new RingtoetsGuiPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ // Call
+ var image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.FailureMechanismIcon, image);
+ }
+ }
+
+ [Test]
+ public void ForeColor_Always_ReturnsControlText()
+ {
+ // Setup
+ using (var plugin = new RingtoetsGuiPlugin())
+ {
+ var info = GetInfo(plugin);
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new StandAloneFailureMechanism("C", "C");
+ var context = new StandAloneFailureMechanismContext(failureMechanism, assessmentSection);
+
+ // Call
+ var textColor = info.ForeColor(context);
+
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), textColor);
+
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void ChildNodeObjects_FailureMechanismIsRelevant_ReturnFoldersWithInputAndOutput()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsGuiPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ var failureMechanism = new StandAloneFailureMechanism("test", "C");
+ failureMechanism.AddSection(new FailureMechanismSection("A", new[]
+ {
+ new Point2D(1, 2),
+ new Point2D(5, 6)
+ }));
+ var failureMechanismContext = new StandAloneFailureMechanismContext(failureMechanism, assessmentSection);
+
+ // Call
+ object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray();
+
+ // Assert
+ Assert.AreEqual(2, children.Length);
+ var inputFolder = (CategoryTreeFolder) children[0];
+ Assert.AreEqual("Invoer", inputFolder.Name);
+ Assert.AreEqual(TreeFolderCategory.Input, inputFolder.Category);
+
+ var failureMechanismSectionsContext = (FailureMechanismSectionsContext) inputFolder.Contents[0];
+ CollectionAssert.AreEqual(failureMechanism.Sections, failureMechanismSectionsContext.WrappedData);
+ Assert.AreSame(failureMechanism, failureMechanismSectionsContext.ParentFailureMechanism);
+ Assert.AreSame(assessmentSection, failureMechanismSectionsContext.ParentAssessmentSection);
+
+ Assert.AreSame(failureMechanism.Locations, inputFolder.Contents[1]);
+ Assert.AreSame(failureMechanism.BoundaryConditions, inputFolder.Contents[2]);
+
+ var commentContext = (CommentContext) inputFolder.Contents[3];
+ Assert.IsNotNull(commentContext);
+ Assert.AreSame(failureMechanism, commentContext.CommentContainer);
+
+ var outputFolder = (CategoryTreeFolder) children[1];
+ Assert.AreEqual("Uitvoer", outputFolder.Name);
+ Assert.AreEqual(TreeFolderCategory.Output, outputFolder.Category);
+
+ var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputFolder.Contents[0];
+ Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism);
+ Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.SectionResults);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ChildNodeObjects_FailureMechanismIsNotRelevant_ReturnOnlyFailureMechanismComments()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsGuiPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ var failureMechanism = new StandAloneFailureMechanism("test", "C")
+ {
+ IsRelevant = false
+ };
+ failureMechanism.AddSection(new FailureMechanismSection("A", new[]
+ {
+ new Point2D(1, 2),
+ new Point2D(5, 6)
+ }));
+ var failureMechanismContext = new StandAloneFailureMechanismContext(failureMechanism, assessmentSection);
+
+ // Call
+ object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray();
+
+ // Assert
+ Assert.AreEqual(1, children.Length);
+ var commentContext = (CommentContext)children[0];
+ Assert.AreSame(failureMechanism, commentContext.CommentContainer);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_FailureMechanismIsRelevant_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ using (var treeView = new TreeViewControl())
+ {
+ var failureMechanism = new StandAloneFailureMechanism("A", "C");
+ var assessmentSection = mocks.Stub();
+ var context = new StandAloneFailureMechanismContext(failureMechanism, assessmentSection);
+
+ var gui = mocks.StrictMock();
+ var menuBuilderMock = mocks.StrictMock();
+
+ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddImportItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddExportItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ gui.Expect(cmp => cmp.Get(context, treeView)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsGuiPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(context, assessmentSection, treeView);
+ }
+ // Assert
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_FailureMechanismIsNotRelevant_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ using (var treeView = new TreeViewControl())
+ {
+ var failureMechanism = new StandAloneFailureMechanism("A", "C")
+ {
+ IsRelevant = false
+ };
+ var assessmentSection = mocks.Stub();
+ var context = new StandAloneFailureMechanismContext(failureMechanism, assessmentSection);
+
+ var gui = mocks.StrictMock();
+ var menuBuilderMock = mocks.StrictMock();
+
+ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilderMock);
+ menuBuilderMock.Expect(mb => mb.Build()).Return(null);
+
+ gui.Expect(cmp => cmp.Get(context, treeView)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsGuiPlugin())
+ {
+ var info = GetInfo(plugin);
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(context, assessmentSection, treeView);
+ }
+ // Assert
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_FailureMechanismIsRelevant_IsRelevantEnabledCalculateAllAndClearAllItemDisabled()
+ {
+ // Setup
+ using (var treeView = new TreeViewControl())
+ {
+ var assessmentSection = mocks.Stub();
+ var failureMechanism = new StandAloneFailureMechanism("A", "C");
+ var context = new StandAloneFailureMechanismContext(failureMechanism, assessmentSection);
+
+ var menuBuilderMock = new CustomItemsOnlyContextMenuBuilder();
+
+ var gui = mocks.StrictMock();
+ gui.Expect(cmp => cmp.Get(context, treeView)).Return(menuBuilderMock);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+
+ mocks.ReplayAll();
+
+ using (var plugin = new RingtoetsGuiPlugin())
+ {
+ plugin.Gui = gui;
+
+ var info = GetInfo(plugin);
+
+ // Call
+ var menu = info.ContextMenuStrip(context, assessmentSection, treeView);
+
+ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRelevancyIndex,
+ RingtoetsCommonFormsResources.FailureMechanismContextMenuStrip_Is_relevant,
+ RingtoetsCommonFormsResources.FailureMechanismContextMenuStrip_Is_relevant_Tooltip,
+ RingtoetsCommonFormsResources.Checkbox_ticked);
+ TestHelper.AssertContextMenuStripContainsItem(menu, 2,
+ RingtoetsCommonFormsResources.Calculate_all,
+ RingtoetsCommonFormsResources.Calculate_all_ToolTip,
+ RingtoetsCommonFormsResources.CalculateAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, 3,
+ RingtoetsCommonFormsResources.Clear_all_output,
+ RingtoetsCommonFormsResources.Clear_all_output_ToolTip,
+ RingtoetsCommonFormsResources.ClearIcon,
+ false);
+ }
+
+ // Assert
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_FailureMechanismIsRelevantAndClickOnIsRelevantItem_MakeFailureMechanismNotRelevant()
+ {
+ // Setup
+ var failureMechanismObserver = mocks.Stub();
+ failureMechanismObserver.Expect(o => o.UpdateObserver());
+
+ var failureMechanism = new StandAloneFailureMechanism("A", "C")
+ {
+ IsRelevant = true
+ };
+ failureMechanism.Attach(failureMechanismObserver);
+
+ var assessmentSection = mocks.Stub();
+ var failureMechanismContext = new StandAloneFailureMechanismContext(failureMechanism, assessmentSection);
+
+ var viewCommands = mocks.StrictMock();
+ viewCommands.Expect(vs => vs.RemoveAllViewsForItem(failureMechanismContext));
+
+ var treeViewControl = mocks.StrictMock();
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ var gui = mocks.StrictMock();
+ gui.Stub(g => g.ViewCommands).Return(viewCommands);
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ gui.Expect(g => g.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+
+ mocks.ReplayAll();
+
+ using (var guiPlugin = new RingtoetsGuiPlugin())
+ {
+ guiPlugin.Gui = gui;
+
+ var info = GetInfo(guiPlugin);
+
+ var contextMenu = info.ContextMenuStrip(failureMechanismContext, null, treeViewControl);
+
+ // Call
+ contextMenu.Items[contextMenuRelevancyIndex].PerformClick();
+
+ // Assert
+ Assert.IsFalse(failureMechanism.IsRelevant);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ContextMenuStrip_FailureMechanismIsNotRelevantAndClickOnIsRelevantItem_MakeFailureMechanismRelevant()
+ {
+ // Setup
+ var failureMechanismObserver = mocks.Stub();
+ failureMechanismObserver.Expect(o => o.UpdateObserver());
+
+ var failureMechanism = new StandAloneFailureMechanism("A", "C")
+ {
+ IsRelevant = false
+ };
+ failureMechanism.Attach(failureMechanismObserver);
+
+ var assessmentSection = mocks.Stub();
+ var failureMechanismContext = new StandAloneFailureMechanismContext(failureMechanism, assessmentSection);
+
+ var treeViewControl = mocks.StrictMock();
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ var gui = mocks.StrictMock();
+ gui.Stub(g => g.ProjectOpened += null).IgnoreArguments();
+ gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
+ gui.Expect(g => g.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+
+ mocks.ReplayAll();
+
+ using (var guiPlugin = new RingtoetsGuiPlugin())
+ {
+ guiPlugin.Gui = gui;
+
+ var info = GetInfo(guiPlugin);
+
+ var contextMenu = info.ContextMenuStrip(failureMechanismContext, null, treeViewControl);
+
+ // Call
+ contextMenu.Items[contextMenuRelevancyIndex].PerformClick();
+
+ // Assert
+ Assert.IsTrue(failureMechanism.IsRelevant);
+ }
+ mocks.VerifyAll();
+ }
+
+ private TreeNodeInfo GetInfo(RingtoetsGuiPlugin guiPlugin)
+ {
+ return guiPlugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(StandAloneFailureMechanismContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismContributionViewTest.cs
===================================================================
diff -u -r13fcf9943a26918929a3ada0363c2414480db077 -r23d7af54feb72aa59fa17acb00d29a16921f1b94
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismContributionViewTest.cs (.../FailureMechanismContributionViewTest.cs) (revision 13fcf9943a26918929a3ada0363c2414480db077)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismContributionViewTest.cs (.../FailureMechanismContributionViewTest.cs) (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -200,7 +200,7 @@
var testName = "testName";
var testCode = "testCode";
- var someMechanism = new FailureMechanismPlaceholder(testName, testCode);
+ var someMechanism = new StandAloneFailureMechanism(testName, testCode);
var assessmentSection = mockRepository.Stub();
assessmentSection.Stub(section => section.GetFailureMechanisms())
.Return(Enumerable.Empty());
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs
===================================================================
diff -u -r4c81f998de5bd6df7e7c3119f75e1dd37c09ee2e -r23d7af54feb72aa59fa17acb00d29a16921f1b94
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision 4c81f998de5bd6df7e7c3119f75e1dd37c09ee2e)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsGuiPluginTest.cs (.../RingtoetsGuiPluginTest.cs) (revision 23d7af54feb72aa59fa17acb00d29a16921f1b94)
@@ -195,8 +195,8 @@
Assert.IsNull(hydraulicBoundaryDatabaseProperties.GetObjectPropertiesData);
Assert.IsNull(hydraulicBoundaryDatabaseProperties.AfterCreate);
- var failureMechanismPlaceholderProperties = propertyInfos.Single(pi => pi.DataType == typeof(FailureMechanismPlaceholderContext));
- Assert.AreEqual(typeof(FailureMechanismPlaceholderContextProperties), failureMechanismPlaceholderProperties.PropertyObjectType);
+ var failureMechanismPlaceholderProperties = propertyInfos.Single(pi => pi.DataType == typeof(StandAloneFailureMechanismContext));
+ Assert.AreEqual(typeof(StandAloneFailureMechanismContextProperties), failureMechanismPlaceholderProperties.PropertyObjectType);
Assert.IsNull(failureMechanismPlaceholderProperties.AdditionalDataCheck);
Assert.IsNull(failureMechanismPlaceholderProperties.GetObjectPropertiesData);
Assert.IsNull(failureMechanismPlaceholderProperties.AfterCreate);
@@ -260,7 +260,7 @@
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(IAssessmentSection)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ReferenceLineContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(PlaceholderWithReadonlyName)));
- Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismPlaceholderContext)));
+ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(StandAloneFailureMechanismContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(CategoryTreeFolder)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismSectionsContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailureMechanismContributionContext)));