Fisheye: Tag ebc303ada2059650f076f20b2f9e0e30b578a593 refers to a dead (removed) revision in file `Riskeer/Integration/src/Riskeer.Integration.Forms/PresentationObjects/FailurePathsStateRootContext.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Integration/src/Riskeer.Integration.Forms/PresentationObjects/RegistrationStateRootContext.cs
===================================================================
diff -u
--- Riskeer/Integration/src/Riskeer.Integration.Forms/PresentationObjects/RegistrationStateRootContext.cs (revision 0)
+++ Riskeer/Integration/src/Riskeer.Integration.Forms/PresentationObjects/RegistrationStateRootContext.cs (revision ebc303ada2059650f076f20b2f9e0e30b578a593)
@@ -0,0 +1,42 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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 Riskeer.Integration.Data;
+
+namespace Riskeer.Integration.Forms.PresentationObjects
+{
+ ///
+ /// Presentation object for the registration state.
+ ///
+ public class RegistrationStateRootContext : StateRootContext
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The which the
+ /// belongs to.
+ /// Thrown when
+ /// is null.
+ public RegistrationStateRootContext(AssessmentSection wrappedData)
+ : base(wrappedData) {}
+ }
+}
\ No newline at end of file
Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs
===================================================================
diff -u -rf6ee45a6916d6e5aa83cb9f49417a06f4f1439b6 -rebc303ada2059650f076f20b2f9e0e30b578a593
--- Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision f6ee45a6916d6e5aa83cb9f49417a06f4f1439b6)
+++ Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision ebc303ada2059650f076f20b2f9e0e30b578a593)
@@ -215,7 +215,7 @@
{
if (project is RiskeerProject riskeerProject)
{
- return new FailurePathsStateRootContext(riskeerProject.AssessmentSection);
+ return new RegistrationStateRootContext(riskeerProject.AssessmentSection);
}
return null;
@@ -407,7 +407,7 @@
CloseForData = CloseAssessmentSectionViewForData
};
- yield return new RiskeerViewInfo(() => Gui)
+ yield return new RiskeerViewInfo(() => Gui)
{
GetViewName = (view, context) => RiskeerFormsResources.AssessmentSectionMap_DisplayName,
CreateInstance = context => new AssessmentSectionExtendedView(context.WrappedData),
@@ -729,9 +729,9 @@
CalculationsStateRootContextChildNodeObjects,
CalculationsStateRootContextMenuStrip);
- yield return CreateStateRootTreeNodeInfo(
- FailurePathsStateRootContextChildNodeObjects,
- FailurePathsStateRootContextMenuStrip);
+ yield return CreateStateRootTreeNodeInfo(
+ RegistrationStateRootContextChildNodeObjects,
+ RegistrationStateRootContextMenuStrip);
yield return new TreeNodeInfo
{
@@ -1821,9 +1821,9 @@
#endregion
- #region FailurePathsStateRootContext TreeNodeInfo
+ #region RegistrationStateRootContext TreeNodeInfo
- private static object[] FailurePathsStateRootContextChildNodeObjects(FailurePathsStateRootContext nodeData)
+ private static object[] RegistrationStateRootContextChildNodeObjects(RegistrationStateRootContext nodeData)
{
AssessmentSection assessmentSection = nodeData.WrappedData;
@@ -1836,7 +1836,7 @@
};
}
- private ContextMenuStrip FailurePathsStateRootContextMenuStrip(FailurePathsStateRootContext nodeData,
+ private ContextMenuStrip RegistrationStateRootContextMenuStrip(RegistrationStateRootContext nodeData,
object parentData, TreeViewControl treeViewControl)
{
return Gui.Get(nodeData, treeViewControl)
Fisheye: Tag ebc303ada2059650f076f20b2f9e0e30b578a593 refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PresentationObjects/FailurePathsStateRootContextTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PresentationObjects/RegistrationStateRootContextTest.cs
===================================================================
diff -u
--- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PresentationObjects/RegistrationStateRootContextTest.cs (revision 0)
+++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PresentationObjects/RegistrationStateRootContextTest.cs (revision ebc303ada2059650f076f20b2f9e0e30b578a593)
@@ -0,0 +1,46 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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 Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Integration.Data;
+using Riskeer.Integration.Forms.PresentationObjects;
+
+namespace Riskeer.Integration.Forms.Test.PresentationObjects
+{
+ [TestFixture]
+ public class RegistrationStateRootContextTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+
+ // Call
+ var context = new RegistrationStateRootContext(assessmentSection);
+
+ // Assert
+ Assert.IsInstanceOf(context);
+ Assert.AreSame(assessmentSection, context.WrappedData);
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs
===================================================================
diff -u -r954f89a72b0428c6e6441eab69cc0400514e11ab -rebc303ada2059650f076f20b2f9e0e30b578a593
--- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs (.../RiskeerPluginTest.cs) (revision 954f89a72b0428c6e6441eab69cc0400514e11ab)
+++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs (.../RiskeerPluginTest.cs) (revision ebc303ada2059650f076f20b2f9e0e30b578a593)
@@ -428,7 +428,7 @@
PluginTestHelper.AssertViewInfoDefined(
viewInfos,
- typeof(FailurePathsStateRootContext),
+ typeof(RegistrationStateRootContext),
typeof(AssessmentSectionExtendedView));
PluginTestHelper.AssertViewInfoDefined(
@@ -573,7 +573,7 @@
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(AssessmentSectionStateRootContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(HydraulicLoadsStateRootContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(CalculationsStateRootContext)));
- Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(FailurePathsStateRootContext)));
+ Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(RegistrationStateRootContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(BackgroundData)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(NormContext)));
Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(ReferenceLineContext)));
Fisheye: Tag ebc303ada2059650f076f20b2f9e0e30b578a593 refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/StateInfos/FailurePathsStateInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/StateInfos/RegistrationStateInfoTest.cs
===================================================================
diff -u
--- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/StateInfos/RegistrationStateInfoTest.cs (revision 0)
+++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/StateInfos/RegistrationStateInfoTest.cs (revision ebc303ada2059650f076f20b2f9e0e30b578a593)
@@ -0,0 +1,95 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.Linq;
+using Core.Common.Base.Data;
+using Core.Gui.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Integration.Data;
+using Riskeer.Integration.Forms.PresentationObjects;
+
+namespace Riskeer.Integration.Plugin.Test.StateInfos
+{
+ [TestFixture]
+ public class RegistrationStateInfoTest
+ {
+ private RiskeerPlugin plugin;
+ private StateInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ plugin = new RiskeerPlugin();
+ info = plugin.GetStateInfos().First(si => si.Name == "Registratie\r\nen assemblage");
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual("\uE903", info.Symbol);
+ }
+
+ [Test]
+ public void GetRootData_RiskeerProject_ReturnsExpectedRootData()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ var project = new RiskeerProject(assessmentSection);
+
+ // Call
+ object rootData = info.GetRootData(project);
+
+ // Assert
+ Assert.IsNotNull(rootData);
+ Assert.IsInstanceOf(rootData);
+
+ var registrationStateRootContext = (RegistrationStateRootContext) rootData;
+ Assert.AreSame(assessmentSection, registrationStateRootContext.WrappedData);
+ }
+
+ [Test]
+ public void GetRootData_OtherThanRiskeerProject_ReturnsNull()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var project = mockRepository.StrictMock();
+
+ mockRepository.ReplayAll();
+
+ // Call
+ object rootData = info.GetRootData(project);
+
+ // Assert
+ Assert.IsNull(rootData);
+
+ mockRepository.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag ebc303ada2059650f076f20b2f9e0e30b578a593 refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/FailurePathsStateRootContextTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/RegistrationStateRootContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/RegistrationStateRootContextTreeNodeInfoTest.cs (revision 0)
+++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/RegistrationStateRootContextTreeNodeInfoTest.cs (revision ebc303ada2059650f076f20b2f9e0e30b578a593)
@@ -0,0 +1,277 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.Controls.TreeView;
+using Core.Common.TestUtil;
+using Core.Gui;
+using Core.Gui.ContextMenu;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Plugin.TestUtil;
+using Riskeer.Integration.Data;
+using Riskeer.Integration.Forms.PresentationObjects;
+using RiskeerIntegrationFormsResources = Riskeer.Integration.Forms.Properties.Resources;
+
+namespace Riskeer.Integration.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class RegistrationStateRootContextTreeNodeInfoTest
+ {
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Assert
+ Assert.IsNotNull(info.Text);
+ Assert.IsNull(info.ForeColor);
+ Assert.IsNotNull(info.Image);
+ Assert.IsNotNull(info.ContextMenuStrip);
+ Assert.IsNotNull(info.EnsureVisibleOnCreate);
+ Assert.IsNotNull(info.ExpandOnCreate);
+ Assert.IsNotNull(info.ChildNodeObjects);
+ Assert.IsNotNull(info.CanRename);
+ Assert.IsNotNull(info.OnNodeRenamed);
+ Assert.IsNotNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.CheckedState);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+ }
+
+ [Test]
+ public void Text_WithContext_ReturnsName()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ Name = "ttt"
+ };
+
+ var context = new RegistrationStateRootContext(assessmentSection);
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ string text = info.Text(context);
+
+ // Assert
+ Assert.AreEqual(assessmentSection.Name, text);
+ }
+ }
+
+ [Test]
+ public void Image_Always_ReturnsSetImage()
+ {
+ // Setup
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ Image image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RiskeerIntegrationFormsResources.AssessmentSectionFolderIcon, image);
+ }
+ }
+
+ [Test]
+ public void EnsureVisibleOnCreate_Always_ReturnsTrue()
+ {
+ // Setup
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ bool result = info.EnsureVisibleOnCreate(null, null);
+
+ // Assert
+ Assert.IsTrue(result);
+ }
+ }
+
+ [Test]
+ public void ExpandOnCreate_Always_ReturnsTrue()
+ {
+ // Setup
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ bool result = info.ExpandOnCreate(null);
+
+ // Assert
+ Assert.IsTrue(result);
+ }
+ }
+
+ [Test]
+ public void ChildNodeObjects_Always_ReturnsChildrenOfData()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ var context = new RegistrationStateRootContext(assessmentSection);
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ object[] objects = info.ChildNodeObjects(context).ToArray();
+
+ // Assert
+ Assert.AreEqual(4, objects.Length);
+
+ var assemblyGroupsContext = (FailureMechanismSectionAssemblyGroupsContext) objects[0];
+ Assert.AreSame(assessmentSection, assemblyGroupsContext.WrappedData);
+
+ var genericFailureMechanismsContext = (GenericFailureMechanismsContext) objects[1];
+ Assert.AreSame(assessmentSection, genericFailureMechanismsContext.WrappedData);
+
+ var specificFailureMechanismsContext = (SpecificFailureMechanismsContext) objects[2];
+ Assert.AreSame(assessmentSection.SpecificFailureMechanisms, specificFailureMechanismsContext.WrappedData);
+ Assert.AreSame(assessmentSection, specificFailureMechanismsContext.AssessmentSection);
+
+ var assemblyResultsContext = (AssemblyResultsContext) objects[3];
+ Assert.AreSame(assessmentSection, assemblyResultsContext.WrappedData);
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_Always_CallsBuilder()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var menuBuilder = mocks.StrictMock();
+ using (mocks.Ordered())
+ {
+ menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddRenameItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.Build()).Return(null);
+ }
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ IGui gui = StubFactory.CreateGuiStub(mocks);
+ gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilder);
+ mocks.ReplayAll();
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(null, null, treeViewControl);
+ }
+ }
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CanRename_Always_ReturnsTrue()
+ {
+ // Setup
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+
+ // Call
+ bool canRename = info.CanRename(null, null);
+
+ // Assert
+ Assert.IsTrue(canRename);
+ }
+ }
+
+ [Test]
+ public void OnNodeRenamed_WithData_SetProjectNameWithNotification()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var observer = mocks.Stub();
+ observer.Expect(o => o.UpdateObserver());
+ mocks.ReplayAll();
+
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ var context = new RegistrationStateRootContext(assessmentSection);
+ context.Attach(observer);
+
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+ // Call
+ const string newName = "New Name";
+ info.OnNodeRenamed(context, newName);
+
+ // Assert
+ Assert.AreEqual(newName, assessmentSection.Name);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CanRemove_Always_ReturnsFalse()
+ {
+ // Setup
+ using (var plugin = new RiskeerPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+ // Call
+ bool canRemove = info.CanRemove(null, null);
+
+ // Assert
+ Assert.IsFalse(canRemove);
+ }
+ }
+
+ private static TreeNodeInfo GetInfo(RiskeerPlugin plugin)
+ {
+ return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(RegistrationStateRootContext));
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag ebc303ada2059650f076f20b2f9e0e30b578a593 refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ViewInfos/FailurePathsStateRootContextViewInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ViewInfos/RegistrationStateRootContextViewInfoTest.cs
===================================================================
diff -u
--- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ViewInfos/RegistrationStateRootContextViewInfoTest.cs (revision 0)
+++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/ViewInfos/RegistrationStateRootContextViewInfoTest.cs (revision ebc303ada2059650f076f20b2f9e0e30b578a593)
@@ -0,0 +1,117 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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 Core.Common.Controls.Views;
+using Core.Common.TestUtil;
+using Core.Gui.Plugin;
+using NUnit.Framework;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Integration.Data;
+using Riskeer.Integration.Forms.PresentationObjects;
+using Riskeer.Integration.Forms.Views;
+
+namespace Riskeer.Integration.Plugin.Test.ViewInfos
+{
+ [TestFixture]
+ public class RegistrationStateRootContextViewInfoTest
+ {
+ private RiskeerPlugin plugin;
+ private ViewInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ plugin = new RiskeerPlugin();
+ info = plugin.GetViewInfos().First(tni => tni.DataType == typeof(RegistrationStateRootContext));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual(typeof(AssessmentSectionExtendedView), info.ViewType);
+ }
+
+ [Test]
+ public void GetViewName_Always_ReturnsViewName()
+ {
+ // Call
+ string viewName = info.GetViewName(null, null);
+
+ // Assert
+ Assert.AreEqual("Trajectkaart", viewName);
+ }
+
+ [Test]
+ public void CreateInstance_WithContext_ReturnsAssessmentSectionExtendedView()
+ {
+ // Setup
+ var context = new RegistrationStateRootContext(new AssessmentSection(AssessmentSectionComposition.Dike));
+
+ // Call
+ IView view = info.CreateInstance(context);
+
+ // Assert
+ Assert.IsInstanceOf(view);
+ }
+
+ [Test]
+ public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue()
+ {
+ // Setup
+ var random = new Random(21);
+ var assessmentSection = new AssessmentSection(random.NextEnumValue());
+
+ var view = new AssessmentSectionExtendedView(assessmentSection);
+
+ // Call
+ bool closeForData = info.CloseForData(view, assessmentSection);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+
+ [Test]
+ public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse()
+ {
+ // Setup
+ var random = new Random(21);
+ var assessmentSection1 = new AssessmentSection(random.NextEnumValue());
+ var assessmentSection2 = new AssessmentSection(random.NextEnumValue());
+
+ var view = new AssessmentSectionExtendedView(assessmentSection1);
+
+ // Call
+ bool closeForData = info.CloseForData(view, assessmentSection2);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+ }
+}
\ No newline at end of file