Fisheye: Tag 5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46 refers to a dead (removed) revision in file `Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyCategoriesTable.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyGroupsTable.cs
===================================================================
diff -u
--- Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyGroupsTable.cs (revision 0)
+++ Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyGroupsTable.cs (revision 5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46)
@@ -0,0 +1,75 @@
+// 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.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using Core.Common.Controls.DataGrid;
+using Riskeer.AssemblyTool.Data;
+using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources;
+
+namespace Riskeer.Integration.Forms.Views
+{
+ ///
+ /// This class defines a table in which properties of instances are displayed.
+ ///
+ /// The type of the enum to display in the table rows.
+ public class AssemblyGroupsTable : DataGridViewControl
+ where T : struct
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ public AssemblyGroupsTable()
+ {
+ AddColumns();
+ }
+
+ ///
+ /// Sets the given for which the properties
+ /// are shown in the table.
+ ///
+ /// The collection of .
+ public void SetData(IEnumerable> categories)
+ {
+ SetDataSource(categories?.Select(category => new AssemblyCategoryRow(category.Item1, category.Item2, category.Item3)).ToArray());
+ }
+
+ private void AddColumns()
+ {
+ AddTextBoxColumn(nameof(AssemblyCategoryRow.Group),
+ RiskeerCommonFormsResources.AssemblyCategory_Group_DisplayName,
+ true);
+
+ AddColorColumn(nameof(AssemblyCategoryRow.Color),
+ RiskeerCommonFormsResources.AssemblyCategory_Color_DisplayName);
+
+ AddTextBoxColumn(nameof(AssemblyCategoryRow.LowerBoundary),
+ RiskeerCommonFormsResources.AssemblyCategory_LowerBoundary_DisplayName,
+ true);
+
+ AddTextBoxColumn(nameof(AssemblyCategoryRow.UpperBoundary),
+ RiskeerCommonFormsResources.AssemblyCategory_UpperBoundary_DisplayName,
+ true);
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyGroupsView.Designer.cs
===================================================================
diff -u -rd50a1f58ee3fe5506b092cb9b7a68cb2179024a5 -r5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46
--- Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyGroupsView.Designer.cs (.../AssemblyGroupsView.Designer.cs) (revision d50a1f58ee3fe5506b092cb9b7a68cb2179024a5)
+++ Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyGroupsView.Designer.cs (.../AssemblyGroupsView.Designer.cs) (revision 5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46)
@@ -40,7 +40,7 @@
///
private void InitializeComponent()
{
- this.assemblyGroupsTable = new AssemblyCategoriesTable();
+ this.assemblyGroupsTable = new AssemblyGroupsTable();
this.groupBoxPanel = new System.Windows.Forms.Panel();
this.groupBoxPanel.SuspendLayout();
this.groupBox = new System.Windows.Forms.GroupBox();
@@ -88,7 +88,7 @@
#endregion
- private AssemblyCategoriesTable assemblyGroupsTable;
+ private AssemblyGroupsTable assemblyGroupsTable;
private System.Windows.Forms.GroupBox groupBox;
private System.Windows.Forms.Panel groupBoxPanel;
}
Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionAssemblyGroupsView.Designer.cs
===================================================================
diff -u -r0b54409df4232651752190919a46d6c866bb0ad5 -r5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46
--- Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionAssemblyGroupsView.Designer.cs (.../AssessmentSectionAssemblyGroupsView.Designer.cs) (revision 0b54409df4232651752190919a46d6c866bb0ad5)
+++ Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionAssemblyGroupsView.Designer.cs (.../AssessmentSectionAssemblyGroupsView.Designer.cs) (revision 5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46)
@@ -40,19 +40,19 @@
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AssessmentSectionAssemblyGroupsView));
- this.assemblyCategoriesTable = new AssemblyCategoriesTable();
+ this.assemblyGroupsTable = new AssemblyGroupsTable();
this.SuspendLayout();
//
// assessmentSectionAssemblyCategoriesTable
//
- resources.ApplyResources(this.assemblyCategoriesTable, "assemblyCategoriesTable");
- this.assemblyCategoriesTable.MultiSelect = true;
- this.assemblyCategoriesTable.Name = "assemblyCategoriesTable";
- this.assemblyCategoriesTable.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.RowHeaderSelect;
+ resources.ApplyResources(this.assemblyGroupsTable, "assemblyGroupsTable");
+ this.assemblyGroupsTable.MultiSelect = true;
+ this.assemblyGroupsTable.Name = "assemblyGroupsTable";
+ this.assemblyGroupsTable.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.RowHeaderSelect;
//
// FailureMechanismSectionsView
//
- this.Controls.Add(this.assemblyCategoriesTable);
+ this.Controls.Add(this.assemblyGroupsTable);
this.Name = "AssessmentSectionAssemblyGroupsView";
resources.ApplyResources(this, "$this");
this.ResumeLayout(false);
@@ -62,6 +62,6 @@
#endregion
- private AssemblyCategoriesTable assemblyCategoriesTable;
+ private AssemblyGroupsTable assemblyGroupsTable;
}
}
Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionAssemblyGroupsView.cs
===================================================================
diff -u -r0b54409df4232651752190919a46d6c866bb0ad5 -r5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46
--- Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionAssemblyGroupsView.cs (.../AssessmentSectionAssemblyGroupsView.cs) (revision 0b54409df4232651752190919a46d6c866bb0ad5)
+++ Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionAssemblyGroupsView.cs (.../AssessmentSectionAssemblyGroupsView.cs) (revision 5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46)
@@ -85,7 +85,7 @@
private void UpdateTableData()
{
- assemblyCategoriesTable.SetData(
+ assemblyGroupsTable.SetData(
AssemblyToolCategoriesFactory.CreateAssessmentSectionAssemblyCategories(
FailureMechanismContribution.SignalingNorm,
FailureMechanismContribution.LowerLimitNorm)
Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionAssemblyGroupsView.resx
===================================================================
diff -u -r0b54409df4232651752190919a46d6c866bb0ad5 -r5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46
--- Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionAssemblyGroupsView.resx (.../AssessmentSectionAssemblyGroupsView.resx) (revision 0b54409df4232651752190919a46d6c866bb0ad5)
+++ Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssessmentSectionAssemblyGroupsView.resx (.../AssessmentSectionAssemblyGroupsView.resx) (revision 5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46)
@@ -118,30 +118,30 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
+
Fill
-
+
0, 0
-
+
750, 420
-
+
0
-
- assemblyCategoriesTable
+
+ assemblyGroupsTable
-
+
Riskeer.Integration.Forms.Views.AssessmentSectionAssemblyCategoriesTable, Riskeer.Common.Forms, Version=18.1.1.1, Culture=neutral, PublicKeyToken=null
-
+
$this
-
+
0
Fisheye: Tag 5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46 refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssemblyCategoriesTableTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssemblyGroupsTableTest.cs
===================================================================
diff -u
--- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssemblyGroupsTableTest.cs (revision 0)
+++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssemblyGroupsTableTest.cs (revision 5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46)
@@ -0,0 +1,195 @@
+// 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.Drawing;
+using System.Windows.Forms;
+using Core.Common.Controls.DataGrid;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Riskeer.AssemblyTool.Data;
+using Riskeer.Integration.Forms.Views;
+
+namespace Riskeer.Integration.Forms.Test.Views
+{
+ [TestFixture]
+ public class AssemblyGroupsTableTest
+ {
+ private const int assemblyGroupColumnIndex = 0;
+ private const int colorColumnIndex = 1;
+ private const int lowerBoundaryColumnIndex = 2;
+ private const int upperBoundaryColumnIndex = 3;
+
+ [Test]
+ public void Constructor_InitializesWithColumns()
+ {
+ // Call
+ using (var table = new AssemblyGroupsTable())
+ {
+ // Assert
+ Assert.IsInstanceOf(table);
+
+ DataGridViewColumn groupColumn = table.GetColumnFromIndex(assemblyGroupColumnIndex);
+ Assert.AreEqual("Naam", groupColumn.HeaderText);
+ Assert.IsTrue(groupColumn.ReadOnly);
+ Assert.IsInstanceOf(groupColumn);
+
+ DataGridViewColumn colorColumn = table.GetColumnFromIndex(colorColumnIndex);
+ Assert.AreEqual("Kleur", colorColumn.HeaderText);
+ Assert.IsTrue(colorColumn.ReadOnly);
+ Assert.IsInstanceOf(colorColumn);
+
+ DataGridViewColumn lowerBoundaryColumn = table.GetColumnFromIndex(lowerBoundaryColumnIndex);
+ Assert.AreEqual("Ondergrens [1/jaar]", lowerBoundaryColumn.HeaderText);
+ Assert.IsTrue(lowerBoundaryColumn.ReadOnly);
+ Assert.IsInstanceOf(lowerBoundaryColumn);
+
+ DataGridViewColumn upperBoundaryColumn = table.GetColumnFromIndex(upperBoundaryColumnIndex);
+ Assert.AreEqual("Bovengrens [1/jaar]", upperBoundaryColumn.HeaderText);
+ Assert.IsTrue(upperBoundaryColumn.ReadOnly);
+ Assert.IsInstanceOf(upperBoundaryColumn);
+
+ Assert.Throws(() => table.GetColumnFromIndex(upperBoundaryColumnIndex + 1));
+
+ CollectionAssert.IsEmpty(table.Rows);
+ }
+ }
+
+ [Test]
+ public void SetData_NoDataAlreadySet_SetNewData()
+ {
+ // Setup
+ using (var table = new AssemblyGroupsTable())
+ {
+ Tuple[] categories =
+ {
+ CreateAssessmentSectionAssemblyCategory(),
+ CreateAssessmentSectionAssemblyCategory(),
+ CreateAssessmentSectionAssemblyCategory()
+ };
+
+ // Call
+ table.SetData(categories);
+
+ // Assert
+ Assert.AreEqual(categories.Length, table.Rows.Count);
+ }
+ }
+
+ [Test]
+ public void SetData_SetNullDataAfterDataAlreadySet_ClearsData()
+ {
+ // Setup
+ using (var table = new AssemblyGroupsTable())
+ {
+ Tuple[] categories =
+ {
+ CreateAssessmentSectionAssemblyCategory(),
+ CreateAssessmentSectionAssemblyCategory(),
+ CreateAssessmentSectionAssemblyCategory()
+ };
+ table.SetData(categories);
+
+ // Call
+ table.SetData(null);
+
+ // Assert
+ Assert.AreEqual(0, table.Rows.Count);
+ }
+ }
+
+ [Test]
+ public void SetData_SetNewDataAfterDataAlreadySet_ClearDataAndAddNewData()
+ {
+ // Setup
+ using (var table = new AssemblyGroupsTable())
+ {
+ table.SetData(new[]
+ {
+ CreateAssessmentSectionAssemblyCategory()
+ });
+
+ Tuple[] newCategories =
+ {
+ CreateAssessmentSectionAssemblyCategory(),
+ CreateAssessmentSectionAssemblyCategory(),
+ CreateAssessmentSectionAssemblyCategory()
+ };
+
+ // Call
+ table.SetData(newCategories);
+
+ // Assert
+ Assert.AreEqual(newCategories.Length, table.Rows.Count);
+ }
+ }
+
+ [Test]
+ public void SetData_WithData_ExpectedValuesInTable()
+ {
+ // Setup
+ using (var table = new AssemblyGroupsTable())
+ {
+ Tuple[] categories =
+ {
+ CreateAssessmentSectionAssemblyCategory(),
+ CreateAssessmentSectionAssemblyCategory(),
+ CreateAssessmentSectionAssemblyCategory()
+ };
+
+ // Call
+ table.SetData(categories);
+
+ // Assert
+ Assert.AreEqual(categories.Length, table.Rows.Count);
+ for (var i = 0; i < table.Rows.Count; i++)
+ {
+ Tuple category = categories[i];
+ DataGridViewCellCollection rowCells = table.Rows[i].Cells;
+
+ Assert.AreEqual(category.Item3, rowCells[assemblyGroupColumnIndex].Value);
+ Assert.AreEqual(category.Item2, rowCells[colorColumnIndex].Value);
+ Assert.AreEqual(category.Item1.LowerBoundary, rowCells[lowerBoundaryColumnIndex].Value);
+ Assert.AreEqual(category.Item1.UpperBoundary, rowCells[upperBoundaryColumnIndex].Value);
+ }
+ }
+ }
+
+ private static Tuple CreateAssessmentSectionAssemblyCategory()
+ {
+ var random = new Random(39);
+ return new Tuple(new TestAssemblyCategory(random.NextDouble(), random.NextDouble()),
+ Color.FromKnownColor(random.NextEnumValue()),
+ random.NextEnumValue());
+ }
+
+ private class TestAssemblyCategory : AssemblyGroupBoundaries
+ {
+ public TestAssemblyCategory(double lowerBoundary, double upperBoundary)
+ : base(lowerBoundary, upperBoundary) {}
+ }
+
+ private enum TestAssemblyCategoryGroup
+ {
+ I = 1
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssemblyGroupsViewTest.cs
===================================================================
diff -u -r5f606ac4712b01dafd9d17bd45a885d824e72d3b -r5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46
--- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssemblyGroupsViewTest.cs (.../AssemblyGroupsViewTest.cs) (revision 5f606ac4712b01dafd9d17bd45a885d824e72d3b)
+++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssemblyGroupsViewTest.cs (.../AssemblyGroupsViewTest.cs) (revision 5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46)
@@ -66,10 +66,10 @@
// Call
using (var view = new AssemblyGroupsView(assessmentSection))
{
- AssemblyCategoriesTable failureMechanismSectionCategoriesTable = GetAssemblyGroupsTable(view);
+ AssemblyGroupsTable failureMechanismSectionGroupsTable = GetAssemblyGroupsTable(view);
// Assert
- Assert.IsEmpty(failureMechanismSectionCategoriesTable.Rows);
+ Assert.IsEmpty(failureMechanismSectionGroupsTable.Rows);
}
}
}
@@ -100,7 +100,7 @@
Assert.AreEqual(DockStyle.Fill, groupBox.Dock);
Assert.AreEqual("Duidingsklassen", groupBox.Text);
- AssemblyCategoriesTable assemblyGroupsTable = GetAssemblyGroupsTable(view);
+ AssemblyGroupsTable assemblyGroupsTable = GetAssemblyGroupsTable(view);
Assert.AreEqual(DockStyle.Fill, assemblyGroupsTable.Dock);
}
}
@@ -147,7 +147,7 @@
// Call
using (var view = new AssemblyGroupsView(assessmentSection))
{
- AssemblyCategoriesTable assemblyGroupsTable = GetAssemblyGroupsTable(view);
+ AssemblyGroupsTable assemblyGroupsTable = GetAssemblyGroupsTable(view);
// Assert
Assert.AreEqual(1, assemblyGroupsTable.Rows.Count);
@@ -179,11 +179,11 @@
using (var view = new AssemblyGroupsView(assessmentSection))
{
- AssemblyCategoriesTable failureMechanismSectionCategoriesTable = GetAssemblyGroupsTable(view);
+ AssemblyGroupsTable failureMechanismSectionGroupsTable = GetAssemblyGroupsTable(view);
// Precondition
int groupBoundaries = output.Count;
- Assert.AreEqual(groupBoundaries, failureMechanismSectionCategoriesTable.Rows.Count);
+ Assert.AreEqual(groupBoundaries, failureMechanismSectionGroupsTable.Rows.Count);
int newGroupBoundaries = random.Next(1, 10);
for (var i = 1; i <= newGroupBoundaries; i++)
@@ -195,15 +195,15 @@
assessmentSection.FailureMechanismContribution.NotifyObservers();
// Then
- Assert.AreEqual(groupBoundaries + newGroupBoundaries, failureMechanismSectionCategoriesTable.Rows.Count);
+ Assert.AreEqual(groupBoundaries + newGroupBoundaries, failureMechanismSectionGroupsTable.Rows.Count);
}
}
}
- private static AssemblyCategoriesTable GetAssemblyGroupsTable(
+ private static AssemblyGroupsTable GetAssemblyGroupsTable(
AssemblyGroupsView view)
{
- return ControlTestHelper.GetControls>(
+ return ControlTestHelper.GetControls>(
view, "assemblyGroupsTable").Single();
}
Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssessmentSectionAssemblyGroupsViewTest.cs
===================================================================
diff -u -r0b54409df4232651752190919a46d6c866bb0ad5 -r5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46
--- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssessmentSectionAssemblyGroupsViewTest.cs (.../AssessmentSectionAssemblyGroupsViewTest.cs) (revision 0b54409df4232651752190919a46d6c866bb0ad5)
+++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssessmentSectionAssemblyGroupsViewTest.cs (.../AssessmentSectionAssemblyGroupsViewTest.cs) (revision 5d3fcfc76fcab0152f1b9046a4b0cdd84f08ba46)
@@ -69,7 +69,7 @@
Assert.AreEqual(1, view.Controls.Count);
Assert.AreSame(failureMechanismContribution, view.FailureMechanismContribution);
- AssemblyCategoriesTable tableControl = GetCategoriesTable(view);
+ AssemblyGroupsTable tableControl = GetCategoriesTable(view);
Assert.AreEqual(DockStyle.Fill, tableControl.Dock);
var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
@@ -98,10 +98,10 @@
var calculatorFactory = (TestAssemblyToolCalculatorFactoryOld) AssemblyToolCalculatorFactoryOld.Instance;
AssemblyCategoriesCalculatorStub calculator = calculatorFactory.LastCreatedAssemblyCategoriesCalculator;
- AssemblyCategoriesTable categoriesTable = GetCategoriesTable(view);
+ AssemblyGroupsTable groupsTable = GetCategoriesTable(view);
// Precondition
- Assert.AreEqual(calculator.AssessmentSectionCategoriesOutput.Count(), categoriesTable.Rows.Count);
+ Assert.AreEqual(calculator.AssessmentSectionCategoriesOutput.Count(), groupsTable.Rows.Count);
// When
var newOutput = new[]
@@ -114,15 +114,15 @@
failureMechanismContribution.NotifyObservers();
// Then
- Assert.AreEqual(newOutput.Length, categoriesTable.Rows.Count);
+ Assert.AreEqual(newOutput.Length, groupsTable.Rows.Count);
}
mocks.VerifyAll();
}
- private static AssemblyCategoriesTable GetCategoriesTable(AssessmentSectionAssemblyGroupsView view)
+ private static AssemblyGroupsTable GetCategoriesTable(AssessmentSectionAssemblyGroupsView view)
{
- return ControlTestHelper.GetControls>(
+ return ControlTestHelper.GetControls>(
view, "assemblyCategoriesTable").Single();
}
}