Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/GrassCoverSlipOffInwardsResultViewOldTest.cs =================================================================== diff -u --- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/GrassCoverSlipOffInwardsResultViewOldTest.cs (revision 0) +++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/GrassCoverSlipOffInwardsResultViewOldTest.cs (revision 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b) @@ -0,0 +1,238 @@ +// 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 System.Windows.Forms; +using Core.Common.Util.Reflection; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Riskeer.AssemblyTool.KernelWrapper.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Riskeer.Common.Data.AssemblyTool; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.Controls; +using Riskeer.Common.Forms.TestUtil; +using Riskeer.Common.Forms.Views; +using Riskeer.Common.Primitives; +using Riskeer.Integration.Data.StandAlone; +using Riskeer.Integration.Data.StandAlone.SectionResults; +using Riskeer.Integration.Forms.Views.SectionResultRows; +using Riskeer.Integration.Forms.Views.SectionResultViews; + +namespace Riskeer.Integration.Forms.Test.Views.SectionResultViews +{ + [TestFixture] + public class GrassCoverSlipOffInwardsResultViewOldTest + { + private const int nameColumnIndex = 0; + private const int simpleAssessmentResultIndex = 1; + private const int detailedAssessmentResultIndex = 2; + private const int tailorMadeAssessmentResultIndex = 3; + private const int simpleAssemblyCategoryGroupIndex = 4; + private const int detailedAssemblyCategoryGroupIndex = 5; + private const int tailorMadeAssemblyCategoryGroupIndex = 6; + private const int combinedAssemblyCategoryGroupIndex = 7; + private const int useManualAssemblyIndex = 8; + private const int manualAssemblyCategoryGroupIndex = 9; + private const int columnCount = 10; + + private Form testForm; + + [SetUp] + public void Setup() + { + testForm = new Form(); + } + + [TearDown] + public void TearDown() + { + testForm.Dispose(); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism(); + + // Call + using (var view = new GrassCoverSlipOffInwardsResultViewOld(failureMechanism.SectionResults, failureMechanism)) + { + // Assert + Assert.IsInstanceOf>(view); + Assert.IsNull(view.Data); + Assert.AreSame(failureMechanism, view.FailureMechanism); + } + } + + [Test] + public void GivenFormWithFailureMechanismResultView_ThenExpectedColumnsAreAdded() + { + // Given + using (ShowFailureMechanismResultsView(new GrassCoverSlipOffInwardsFailureMechanism())) + { + // Then + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + Assert.IsInstanceOf(dataGridView.Columns[nameColumnIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[detailedAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[detailedAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[combinedAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[useManualAssemblyIndex]); + Assert.IsInstanceOf(dataGridView.Columns[manualAssemblyCategoryGroupIndex]); + + Assert.AreEqual("Vak", dataGridView.Columns[nameColumnIndex].HeaderText); + Assert.AreEqual("Eenvoudige toets", dataGridView.Columns[simpleAssessmentResultIndex].HeaderText); + Assert.AreEqual("Gedetailleerde toets per vak", dataGridView.Columns[detailedAssessmentResultIndex].HeaderText); + Assert.AreEqual("Toets op maat", dataGridView.Columns[tailorMadeAssessmentResultIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\neenvoudige toets", dataGridView.Columns[simpleAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ngedetailleerde toets per vak", dataGridView.Columns[detailedAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ntoets op maat", dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ngecombineerd", dataGridView.Columns[combinedAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Overschrijf\r\ntoetsoordeel", dataGridView.Columns[useManualAssemblyIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\nhandmatig", dataGridView.Columns[manualAssemblyCategoryGroupIndex].HeaderText); + + Assert.IsTrue(dataGridView.Columns[nameColumnIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[simpleAssessmentResultIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[detailedAssessmentResultIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[tailorMadeAssessmentResultIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[simpleAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[detailedAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[combinedAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[useManualAssemblyIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[manualAssemblyCategoryGroupIndex].ReadOnly); + + Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); + Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); + } + } + + [Test] + public void FailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized() + { + // Setup + var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1") + }); + + // Call + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Assert + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + DataGridViewRowCollection rows = dataGridView.Rows; + Assert.AreEqual(1, rows.Count); + + DataGridViewCellCollection cells = rows[0].Cells; + Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue); + Assert.AreEqual(SimpleAssessmentResultType.None, cells[simpleAssessmentResultIndex].Value); + Assert.AreEqual(DetailedAssessmentResultType.None, cells[detailedAssessmentResultIndex].Value); + Assert.AreEqual(TailorMadeAssessmentResultType.None, cells[tailorMadeAssessmentResultIndex].Value); + Assert.AreEqual("Iv", cells[simpleAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[detailedAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[tailorMadeAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[combinedAssemblyCategoryGroupIndex].Value); + Assert.AreEqual(false, cells[useManualAssemblyIndex].Value); + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroup.None, cells[manualAssemblyCategoryGroupIndex].Value); + } + } + + [Test] + public void GivenFailureMechanismResultsViewWithManualAssembly_WhenShown_ThenManualAssemblyUsed() + { + // Given + var failureMechanism = new GrassCoverSlipOffInwardsFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }); + + GrassCoverSlipOffInwardsFailureMechanismSectionResultOld sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.ManualAssemblyCategoryGroup = ManualFailureMechanismSectionAssemblyCategoryGroup.Iv; + sectionResult.UseManualAssembly = true; + + // When + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + // Then + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroupConverter.Convert(sectionResult.ManualAssemblyCategoryGroup), + calculator.FailureMechanismSectionCategories.Single()); + } + } + + [TestFixture] + public class GrassCoverSlipOffInwardsFailureMechanismResultControlTest : FailureMechanismAssemblyCategoryGroupControlTestFixture< + GrassCoverSlipOffInwardsResultViewOld, + GrassCoverSlipOffInwardsFailureMechanism, + GrassCoverSlipOffInwardsFailureMechanismSectionResultOld, + GrassCoverSlipOffInwardsSectionResultRowOld> + { + protected override GrassCoverSlipOffInwardsResultViewOld CreateResultView(GrassCoverSlipOffInwardsFailureMechanism failureMechanism) + { + return new GrassCoverSlipOffInwardsResultViewOld(failureMechanism.SectionResults, + failureMechanism); + } + } + + private static FailureMechanismAssemblyCategoryGroupControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyCategoryGroupControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private GrassCoverSlipOffInwardsResultViewOld ShowFailureMechanismResultsView( + GrassCoverSlipOffInwardsFailureMechanism failureMechanism) + { + var failureMechanismResultView = new GrassCoverSlipOffInwardsResultViewOld(failureMechanism.SectionResults, + failureMechanism); + testForm.Controls.Add(failureMechanismResultView); + testForm.Show(); + + return failureMechanismResultView; + } + + private static ErrorProvider GetManualAssemblyWarningProvider(FailureMechanismAssemblyCategoryGroupControl control) + { + return TypeUtils.GetField(control, "manualAssemblyWarningProvider"); + } + } +} \ No newline at end of file Fisheye: Tag 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/GrassCoverSlipOffInwardsResultViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/GrassCoverSlipOffOutwardsResultViewOldTest.cs =================================================================== diff -u --- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/GrassCoverSlipOffOutwardsResultViewOldTest.cs (revision 0) +++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/GrassCoverSlipOffOutwardsResultViewOldTest.cs (revision 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b) @@ -0,0 +1,238 @@ +// 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 System.Windows.Forms; +using Core.Common.Util.Reflection; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Riskeer.AssemblyTool.KernelWrapper.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Riskeer.Common.Data.AssemblyTool; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.Controls; +using Riskeer.Common.Forms.TestUtil; +using Riskeer.Common.Forms.Views; +using Riskeer.Common.Primitives; +using Riskeer.Integration.Data.StandAlone; +using Riskeer.Integration.Data.StandAlone.SectionResults; +using Riskeer.Integration.Forms.Views.SectionResultRows; +using Riskeer.Integration.Forms.Views.SectionResultViews; + +namespace Riskeer.Integration.Forms.Test.Views.SectionResultViews +{ + [TestFixture] + public class GrassCoverSlipOffOutwardsResultViewOldTest + { + private const int nameColumnIndex = 0; + private const int simpleAssessmentResultIndex = 1; + private const int detailedAssessmentResultIndex = 2; + private const int tailorMadeAssessmentResultIndex = 3; + private const int simpleAssemblyCategoryGroupIndex = 4; + private const int detailedAssemblyCategoryGroupIndex = 5; + private const int tailorMadeAssemblyCategoryGroupIndex = 6; + private const int combinedAssemblyCategoryGroupIndex = 7; + private const int useManualAssemblyIndex = 8; + private const int manualAssemblyCategoryGroupIndex = 9; + private const int columnCount = 10; + + private Form testForm; + + [SetUp] + public void Setup() + { + testForm = new Form(); + } + + [TearDown] + public void TearDown() + { + testForm.Dispose(); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism(); + + // Call + using (var view = new GrassCoverSlipOffOutwardsResultViewOld(failureMechanism.SectionResults, failureMechanism)) + { + // Assert + Assert.IsInstanceOf>(view); + Assert.IsNull(view.Data); + Assert.AreSame(failureMechanism, view.FailureMechanism); + } + } + + [Test] + public void GivenFormWithFailureMechanismResultView_ThenExpectedColumnsAreAdded() + { + // Given + using (ShowFailureMechanismResultsView(new GrassCoverSlipOffOutwardsFailureMechanism())) + { + // Then + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + Assert.IsInstanceOf(dataGridView.Columns[nameColumnIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[detailedAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[detailedAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[combinedAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[useManualAssemblyIndex]); + Assert.IsInstanceOf(dataGridView.Columns[manualAssemblyCategoryGroupIndex]); + + Assert.AreEqual("Vak", dataGridView.Columns[nameColumnIndex].HeaderText); + Assert.AreEqual("Eenvoudige toets", dataGridView.Columns[simpleAssessmentResultIndex].HeaderText); + Assert.AreEqual("Gedetailleerde toets per vak", dataGridView.Columns[detailedAssessmentResultIndex].HeaderText); + Assert.AreEqual("Toets op maat", dataGridView.Columns[tailorMadeAssessmentResultIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\neenvoudige toets", dataGridView.Columns[simpleAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ngedetailleerde toets per vak", dataGridView.Columns[detailedAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ntoets op maat", dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ngecombineerd", dataGridView.Columns[combinedAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Overschrijf\r\ntoetsoordeel", dataGridView.Columns[useManualAssemblyIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\nhandmatig", dataGridView.Columns[manualAssemblyCategoryGroupIndex].HeaderText); + + Assert.IsTrue(dataGridView.Columns[nameColumnIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[simpleAssessmentResultIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[detailedAssessmentResultIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[tailorMadeAssessmentResultIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[simpleAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[detailedAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[combinedAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[useManualAssemblyIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[manualAssemblyCategoryGroupIndex].ReadOnly); + + Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); + Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); + } + } + + [Test] + public void FailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized() + { + // Setup + var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1") + }); + + // Call + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Assert + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + DataGridViewRowCollection rows = dataGridView.Rows; + Assert.AreEqual(1, rows.Count); + + DataGridViewCellCollection cells = rows[0].Cells; + Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue); + Assert.AreEqual(SimpleAssessmentResultType.None, cells[simpleAssessmentResultIndex].Value); + Assert.AreEqual(DetailedAssessmentResultType.None, cells[detailedAssessmentResultIndex].Value); + Assert.AreEqual(TailorMadeAssessmentResultType.None, cells[tailorMadeAssessmentResultIndex].Value); + Assert.AreEqual("Iv", cells[simpleAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[detailedAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[tailorMadeAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[combinedAssemblyCategoryGroupIndex].Value); + Assert.AreEqual(false, cells[useManualAssemblyIndex].Value); + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroup.None, cells[manualAssemblyCategoryGroupIndex].Value); + } + } + + [Test] + public void GivenFailureMechanismResultsViewWithManualAssembly_WhenShown_ThenManualAssemblyUsed() + { + // Given + var failureMechanism = new GrassCoverSlipOffOutwardsFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }); + + GrassCoverSlipOffOutwardsFailureMechanismSectionResultOld sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.ManualAssemblyCategoryGroup = ManualFailureMechanismSectionAssemblyCategoryGroup.Iv; + sectionResult.UseManualAssembly = true; + + // When + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + // Then + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroupConverter.Convert(sectionResult.ManualAssemblyCategoryGroup), + calculator.FailureMechanismSectionCategories.Single()); + } + } + + [TestFixture] + public class GrassCoverSlipOffOutwardsFailureMechanismResultControlTest : FailureMechanismAssemblyCategoryGroupControlTestFixture< + GrassCoverSlipOffOutwardsResultViewOld, + GrassCoverSlipOffOutwardsFailureMechanism, + GrassCoverSlipOffOutwardsFailureMechanismSectionResultOld, + GrassCoverSlipOffOutwardsSectionResultRowOld> + { + protected override GrassCoverSlipOffOutwardsResultViewOld CreateResultView(GrassCoverSlipOffOutwardsFailureMechanism failureMechanism) + { + return new GrassCoverSlipOffOutwardsResultViewOld(failureMechanism.SectionResults, + failureMechanism); + } + } + + private GrassCoverSlipOffOutwardsResultViewOld ShowFailureMechanismResultsView( + GrassCoverSlipOffOutwardsFailureMechanism failureMechanism) + { + var failureMechanismResultView = new GrassCoverSlipOffOutwardsResultViewOld(failureMechanism.SectionResults, + failureMechanism); + testForm.Controls.Add(failureMechanismResultView); + testForm.Show(); + + return failureMechanismResultView; + } + + private static FailureMechanismAssemblyCategoryGroupControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyCategoryGroupControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private static ErrorProvider GetManualAssemblyWarningProvider(FailureMechanismAssemblyCategoryGroupControl control) + { + return TypeUtils.GetField(control, "manualAssemblyWarningProvider"); + } + } +} \ No newline at end of file Fisheye: Tag 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/GrassCoverSlipOffOutwardsResultViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/MacroStabilityOutwardsResultViewOldTest.cs =================================================================== diff -u --- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/MacroStabilityOutwardsResultViewOldTest.cs (revision 0) +++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/MacroStabilityOutwardsResultViewOldTest.cs (revision 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b) @@ -0,0 +1,272 @@ +// 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 System.Windows.Forms; +using Core.Common.Util.Reflection; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.AssemblyTool.KernelWrapper.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Riskeer.Common.Data.AssemblyTool; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.Controls; +using Riskeer.Common.Forms.TestUtil; +using Riskeer.Common.Forms.Views; +using Riskeer.Common.Primitives; +using Riskeer.Integration.Data.StandAlone; +using Riskeer.Integration.Data.StandAlone.SectionResults; +using Riskeer.Integration.Forms.Views.SectionResultRows; +using Riskeer.Integration.Forms.Views.SectionResultViews; + +namespace Riskeer.Integration.Forms.Test.Views.SectionResultViews +{ + [TestFixture] + public class MacroStabilityOutwardsResultViewOldTest + { + private const int nameColumnIndex = 0; + private const int simpleAssessmentResultIndex = 1; + private const int detailedAssessmentResultIndex = 2; + private const int detailedAssessmentProbabilityIndex = 3; + private const int tailorMadeAssessmentResultIndex = 4; + private const int tailorMadeAssessmentProbabilityIndex = 5; + private const int simpleAssemblyCategoryGroupIndex = 6; + private const int detailedAssemblyCategoryGroupIndex = 7; + private const int tailorMadeAssemblyCategoryGroupIndex = 8; + private const int combinedAssemblyCategoryGroupIndex = 9; + private const int useManualAssemblyIndex = 10; + private const int manualAssemblyCategoryGroupIndex = 11; + private const int columnCount = 12; + + private Form testForm; + + [SetUp] + public void Setup() + { + testForm = new Form(); + } + + [TearDown] + public void TearDown() + { + testForm.Dispose(); + } + + [Test] + public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + // Call + TestDelegate call = () => new MacroStabilityOutwardsResultViewOld(failureMechanism.SectionResults, failureMechanism, null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + // Call + using (var view = new MacroStabilityOutwardsResultViewOld(failureMechanism.SectionResults, failureMechanism, assessmentSection)) + { + // Assert + Assert.IsInstanceOf>(view); + Assert.IsNull(view.Data); + Assert.AreSame(failureMechanism, view.FailureMechanism); + mocks.VerifyAll(); + } + } + + [Test] + public void GivenFormWithFailureMechanismResultView_ThenExpectedColumnsAreAdded() + { + // Given + using (ShowFailureMechanismResultsView(new MacroStabilityOutwardsFailureMechanism())) + { + // Then + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + Assert.IsInstanceOf(dataGridView.Columns[nameColumnIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[detailedAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[detailedAssessmentProbabilityIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssessmentProbabilityIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[detailedAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[combinedAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[useManualAssemblyIndex]); + Assert.IsInstanceOf(dataGridView.Columns[manualAssemblyCategoryGroupIndex]); + + Assert.AreEqual("Vak", dataGridView.Columns[nameColumnIndex].HeaderText); + Assert.AreEqual("Eenvoudige toets", dataGridView.Columns[simpleAssessmentResultIndex].HeaderText); + Assert.AreEqual("Gedetailleerde toets per vak", dataGridView.Columns[detailedAssessmentResultIndex].HeaderText); + Assert.AreEqual("Gedetailleerde toets per vak\r\nfaalkans", dataGridView.Columns[detailedAssessmentProbabilityIndex].HeaderText); + Assert.AreEqual("Toets op maat", dataGridView.Columns[tailorMadeAssessmentResultIndex].HeaderText); + Assert.AreEqual("Toets op maat\r\nfaalkans", dataGridView.Columns[tailorMadeAssessmentProbabilityIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\neenvoudige toets", dataGridView.Columns[simpleAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ngedetailleerde toets per vak", dataGridView.Columns[detailedAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ntoets op maat", dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ngecombineerd", dataGridView.Columns[combinedAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Overschrijf\r\ntoetsoordeel", dataGridView.Columns[useManualAssemblyIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\nhandmatig", dataGridView.Columns[manualAssemblyCategoryGroupIndex].HeaderText); + + Assert.IsTrue(dataGridView.Columns[nameColumnIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[simpleAssessmentResultIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[detailedAssessmentResultIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[detailedAssessmentProbabilityIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[tailorMadeAssessmentResultIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[tailorMadeAssessmentProbabilityIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[simpleAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[detailedAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[combinedAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[useManualAssemblyIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[manualAssemblyCategoryGroupIndex].ReadOnly); + + Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); + Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); + } + } + + [Test] + public void FailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1") + }); + + // Call + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Assert + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + DataGridViewRowCollection rows = dataGridView.Rows; + Assert.AreEqual(1, rows.Count); + + DataGridViewCellCollection cells = rows[0].Cells; + Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue); + Assert.AreEqual(SimpleAssessmentResultType.None, cells[simpleAssessmentResultIndex].Value); + Assert.AreEqual(DetailedAssessmentProbabilityOnlyResultType.Probability, cells[detailedAssessmentResultIndex].Value); + Assert.AreEqual("-", cells[detailedAssessmentProbabilityIndex].FormattedValue); + Assert.AreEqual(TailorMadeAssessmentProbabilityAndDetailedCalculationResultType.None, cells[tailorMadeAssessmentResultIndex].Value); + Assert.AreEqual("-", cells[tailorMadeAssessmentProbabilityIndex].FormattedValue); + Assert.AreEqual("Iv", cells[simpleAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IVv", cells[detailedAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("VIv", cells[tailorMadeAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("VIv", cells[combinedAssemblyCategoryGroupIndex].Value); + Assert.AreEqual(false, cells[useManualAssemblyIndex].Value); + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroup.None, cells[manualAssemblyCategoryGroupIndex].Value); + } + } + + [Test] + public void GivenFailureMechanismResultsViewWithManualAssembly_WhenShown_ThenManualAssemblyUsed() + { + // Given + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }); + + MacroStabilityOutwardsFailureMechanismSectionResultOld sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.ManualAssemblyCategoryGroup = ManualFailureMechanismSectionAssemblyCategoryGroup.Iv; + sectionResult.UseManualAssembly = true; + + // When + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + // Then + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroupConverter.Convert(sectionResult.ManualAssemblyCategoryGroup), + calculator.FailureMechanismSectionCategories.Single()); + } + } + + [TestFixture] + public class MacroStabilityOutwardsFailureMechanismResultControlTest : FailureMechanismAssemblyCategoryGroupControlTestFixture< + MacroStabilityOutwardsResultViewOld, + MacroStabilityOutwardsFailureMechanism, + MacroStabilityOutwardsFailureMechanismSectionResultOld, + MacroStabilityOutwardsSectionResultRowOld> + { + protected override MacroStabilityOutwardsResultViewOld CreateResultView(MacroStabilityOutwardsFailureMechanism failureMechanism) + { + return new MacroStabilityOutwardsResultViewOld(failureMechanism.SectionResults, + failureMechanism, + new AssessmentSectionStub()); + } + } + + private static FailureMechanismAssemblyCategoryGroupControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyCategoryGroupControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private MacroStabilityOutwardsResultViewOld ShowFailureMechanismResultsView( + MacroStabilityOutwardsFailureMechanism failureMechanism) + { + var failureMechanismResultView = new MacroStabilityOutwardsResultViewOld(failureMechanism.SectionResults, + failureMechanism, + new AssessmentSectionStub()); + testForm.Controls.Add(failureMechanismResultView); + testForm.Show(); + + return failureMechanismResultView; + } + + private static ErrorProvider GetManualAssemblyWarningProvider(FailureMechanismAssemblyCategoryGroupControl control) + { + return TypeUtils.GetField(control, "manualAssemblyWarningProvider"); + } + } +} \ No newline at end of file Fisheye: Tag 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/MacroStabilityOutwardsResultViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/MicrostabilityResultViewOldTest.cs =================================================================== diff -u --- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/MicrostabilityResultViewOldTest.cs (revision 0) +++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/MicrostabilityResultViewOldTest.cs (revision 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b) @@ -0,0 +1,238 @@ +// 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 System.Windows.Forms; +using Core.Common.Util.Reflection; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Riskeer.AssemblyTool.KernelWrapper.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Riskeer.Common.Data.AssemblyTool; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.Controls; +using Riskeer.Common.Forms.TestUtil; +using Riskeer.Common.Forms.Views; +using Riskeer.Common.Primitives; +using Riskeer.Integration.Data.StandAlone; +using Riskeer.Integration.Data.StandAlone.SectionResults; +using Riskeer.Integration.Forms.Views.SectionResultRows; +using Riskeer.Integration.Forms.Views.SectionResultViews; + +namespace Riskeer.Integration.Forms.Test.Views.SectionResultViews +{ + [TestFixture] + public class MicrostabilityResultViewOldTest + { + private const int nameColumnIndex = 0; + private const int simpleAssessmentResultIndex = 1; + private const int detailedAssessmentResultIndex = 2; + private const int tailorMadeAssessmentResultIndex = 3; + private const int simpleAssemblyCategoryGroupIndex = 4; + private const int detailedAssemblyCategoryGroupIndex = 5; + private const int tailorMadeAssemblyCategoryGroupIndex = 6; + private const int combinedAssemblyCategoryGroupIndex = 7; + private const int useManualAssemblyIndex = 8; + private const int manualAssemblyCategoryGroupIndex = 9; + private const int columnCount = 10; + + private Form testForm; + + [SetUp] + public void Setup() + { + testForm = new Form(); + } + + [TearDown] + public void TearDown() + { + testForm.Dispose(); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var failureMechanism = new MicrostabilityFailureMechanism(); + + // Call + using (var view = new MicrostabilityResultViewOld(failureMechanism.SectionResults, failureMechanism)) + { + // Assert + Assert.IsInstanceOf>(view); + Assert.IsNull(view.Data); + Assert.AreSame(failureMechanism, view.FailureMechanism); + } + } + + [Test] + public void GivenFormWithFailureMechanismResultView_ThenExpectedColumnsAreAdded() + { + // Given + using (ShowFailureMechanismResultsView(new MicrostabilityFailureMechanism())) + { + // Then + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + Assert.IsInstanceOf(dataGridView.Columns[nameColumnIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[detailedAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[detailedAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[combinedAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[useManualAssemblyIndex]); + Assert.IsInstanceOf(dataGridView.Columns[manualAssemblyCategoryGroupIndex]); + + Assert.AreEqual("Vak", dataGridView.Columns[nameColumnIndex].HeaderText); + Assert.AreEqual("Eenvoudige toets", dataGridView.Columns[simpleAssessmentResultIndex].HeaderText); + Assert.AreEqual("Gedetailleerde toets per vak", dataGridView.Columns[detailedAssessmentResultIndex].HeaderText); + Assert.AreEqual("Toets op maat", dataGridView.Columns[tailorMadeAssessmentResultIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\neenvoudige toets", dataGridView.Columns[simpleAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ngedetailleerde toets per vak", dataGridView.Columns[detailedAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ntoets op maat", dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ngecombineerd", dataGridView.Columns[combinedAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Overschrijf\r\ntoetsoordeel", dataGridView.Columns[useManualAssemblyIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\nhandmatig", dataGridView.Columns[manualAssemblyCategoryGroupIndex].HeaderText); + + Assert.IsTrue(dataGridView.Columns[nameColumnIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[simpleAssessmentResultIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[detailedAssessmentResultIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[tailorMadeAssessmentResultIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[simpleAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[detailedAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[combinedAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[useManualAssemblyIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[manualAssemblyCategoryGroupIndex].ReadOnly); + + Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); + Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); + } + } + + [Test] + public void FailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized() + { + // Setup + var failureMechanism = new MicrostabilityFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1") + }); + + // Call + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Assert + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + DataGridViewRowCollection rows = dataGridView.Rows; + Assert.AreEqual(1, rows.Count); + + DataGridViewCellCollection cells = rows[0].Cells; + Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue); + Assert.AreEqual(SimpleAssessmentResultType.None, cells[simpleAssessmentResultIndex].Value); + Assert.AreEqual(DetailedAssessmentResultType.None, cells[detailedAssessmentResultIndex].Value); + Assert.AreEqual(TailorMadeAssessmentResultType.None, cells[tailorMadeAssessmentResultIndex].Value); + Assert.AreEqual("Iv", cells[simpleAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[detailedAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[tailorMadeAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[combinedAssemblyCategoryGroupIndex].Value); + Assert.AreEqual(false, cells[useManualAssemblyIndex].Value); + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroup.None, cells[manualAssemblyCategoryGroupIndex].Value); + } + } + + [Test] + public void GivenFailureMechanismResultsViewWithManualAssembly_WhenShown_ThenManualAssemblyUsed() + { + // Given + var failureMechanism = new MicrostabilityFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }); + + MicrostabilityFailureMechanismSectionResultOld sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.ManualAssemblyCategoryGroup = ManualFailureMechanismSectionAssemblyCategoryGroup.Iv; + sectionResult.UseManualAssembly = true; + + // When + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + // Then + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroupConverter.Convert(sectionResult.ManualAssemblyCategoryGroup), + calculator.FailureMechanismSectionCategories.Single()); + } + } + + [TestFixture] + public class MicrostabilityFailureMechanismResultControlTest : FailureMechanismAssemblyCategoryGroupControlTestFixture< + MicrostabilityResultViewOld, + MicrostabilityFailureMechanism, + MicrostabilityFailureMechanismSectionResultOld, + MicrostabilitySectionResultRowOld> + { + protected override MicrostabilityResultViewOld CreateResultView(MicrostabilityFailureMechanism failureMechanism) + { + return new MicrostabilityResultViewOld(failureMechanism.SectionResults, + failureMechanism); + } + } + + private static FailureMechanismAssemblyCategoryGroupControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyCategoryGroupControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private MicrostabilityResultViewOld ShowFailureMechanismResultsView( + MicrostabilityFailureMechanism failureMechanism) + { + var failureMechanismResultView = new MicrostabilityResultViewOld(failureMechanism.SectionResults, + failureMechanism); + testForm.Controls.Add(failureMechanismResultView); + testForm.Show(); + + return failureMechanismResultView; + } + + private static ErrorProvider GetManualAssemblyWarningProvider(FailureMechanismAssemblyCategoryGroupControl control) + { + return TypeUtils.GetField(control, "manualAssemblyWarningProvider"); + } + } +} \ No newline at end of file Fisheye: Tag 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/MicrostabilityResultViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/PipingStructureResultViewOldTest.cs =================================================================== diff -u --- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/PipingStructureResultViewOldTest.cs (revision 0) +++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/PipingStructureResultViewOldTest.cs (revision 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b) @@ -0,0 +1,238 @@ +// 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 System.Windows.Forms; +using Core.Common.Util.Reflection; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Riskeer.AssemblyTool.KernelWrapper.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Riskeer.Common.Data.AssemblyTool; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.Controls; +using Riskeer.Common.Forms.TestUtil; +using Riskeer.Common.Forms.Views; +using Riskeer.Common.Primitives; +using Riskeer.Integration.Data.StandAlone; +using Riskeer.Integration.Data.StandAlone.SectionResults; +using Riskeer.Integration.Forms.Views.SectionResultRows; +using Riskeer.Integration.Forms.Views.SectionResultViews; + +namespace Riskeer.Integration.Forms.Test.Views.SectionResultViews +{ + [TestFixture] + public class PipingStructureResultViewOldTest + { + private const int nameColumnIndex = 0; + private const int simpleAssessmentResultIndex = 1; + private const int detailedAssessmentResultIndex = 2; + private const int tailorMadeAssessmentResultIndex = 3; + private const int simpleAssemblyCategoryGroupIndex = 4; + private const int detailedAssemblyCategoryGroupIndex = 5; + private const int tailorMadeAssemblyCategoryGroupIndex = 6; + private const int combinedAssemblyCategoryGroupIndex = 7; + private const int useManualAssemblyIndex = 8; + private const int manualAssemblyCategoryGroupIndex = 9; + private const int columnCount = 10; + + private Form testForm; + + [SetUp] + public void Setup() + { + testForm = new Form(); + } + + [TearDown] + public void TearDown() + { + testForm.Dispose(); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var failureMechanism = new PipingStructureFailureMechanism(); + + // Call + using (var view = new PipingStructureResultViewOld(failureMechanism.SectionResults, failureMechanism)) + { + // Assert + Assert.IsInstanceOf>(view); + Assert.IsNull(view.Data); + Assert.AreSame(failureMechanism, view.FailureMechanism); + } + } + + [Test] + public void GivenFormWithFailureMechanismResultView_ThenExpectedColumnsAreAdded() + { + // Given + using (ShowFailureMechanismResultsView(new PipingStructureFailureMechanism())) + { + // Then + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + Assert.IsInstanceOf(dataGridView.Columns[nameColumnIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[detailedAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[detailedAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[combinedAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[useManualAssemblyIndex]); + Assert.IsInstanceOf(dataGridView.Columns[manualAssemblyCategoryGroupIndex]); + + Assert.AreEqual("Vak", dataGridView.Columns[nameColumnIndex].HeaderText); + Assert.AreEqual("Eenvoudige toets", dataGridView.Columns[simpleAssessmentResultIndex].HeaderText); + Assert.AreEqual("Gedetailleerde toets per vak", dataGridView.Columns[detailedAssessmentResultIndex].HeaderText); + Assert.AreEqual("Toets op maat", dataGridView.Columns[tailorMadeAssessmentResultIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\neenvoudige toets", dataGridView.Columns[simpleAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ngedetailleerde toets per vak", dataGridView.Columns[detailedAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ntoets op maat", dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ngecombineerd", dataGridView.Columns[combinedAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Overschrijf\r\ntoetsoordeel", dataGridView.Columns[useManualAssemblyIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\nhandmatig", dataGridView.Columns[manualAssemblyCategoryGroupIndex].HeaderText); + + Assert.IsTrue(dataGridView.Columns[nameColumnIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[simpleAssessmentResultIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[detailedAssessmentResultIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[tailorMadeAssessmentResultIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[simpleAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[detailedAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[combinedAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[useManualAssemblyIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[manualAssemblyCategoryGroupIndex].ReadOnly); + + Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); + Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); + } + } + + [Test] + public void FailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized() + { + // Setup + var failureMechanism = new PipingStructureFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1") + }); + + // Call + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Assert + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + DataGridViewRowCollection rows = dataGridView.Rows; + Assert.AreEqual(1, rows.Count); + + DataGridViewCellCollection cells = rows[0].Cells; + Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue); + Assert.AreEqual(SimpleAssessmentResultType.None, cells[simpleAssessmentResultIndex].Value); + Assert.AreEqual(DetailedAssessmentResultType.None, cells[detailedAssessmentResultIndex].Value); + Assert.AreEqual(TailorMadeAssessmentResultType.None, cells[tailorMadeAssessmentResultIndex].Value); + Assert.AreEqual("Iv", cells[simpleAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[detailedAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[tailorMadeAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[combinedAssemblyCategoryGroupIndex].Value); + Assert.AreEqual(false, cells[useManualAssemblyIndex].Value); + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroup.None, cells[manualAssemblyCategoryGroupIndex].Value); + } + } + + [Test] + public void GivenFailureMechanismResultsViewWithManualAssembly_WhenShown_ThenManualAssemblyUsed() + { + // Given + var failureMechanism = new PipingStructureFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }); + + PipingStructureFailureMechanismSectionResultOld sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.ManualAssemblyCategoryGroup = ManualFailureMechanismSectionAssemblyCategoryGroup.Iv; + sectionResult.UseManualAssembly = true; + + // When + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + // Then + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroupConverter.Convert(sectionResult.ManualAssemblyCategoryGroup), + calculator.FailureMechanismSectionCategories.Single()); + } + } + + [TestFixture] + public class PipingStructureFailureMechanismResultControlTest : FailureMechanismAssemblyCategoryGroupControlTestFixture< + PipingStructureResultViewOld, + PipingStructureFailureMechanism, + PipingStructureFailureMechanismSectionResultOld, + PipingStructureSectionResultRowOld> + { + protected override PipingStructureResultViewOld CreateResultView(PipingStructureFailureMechanism failureMechanism) + { + return new PipingStructureResultViewOld(failureMechanism.SectionResults, + failureMechanism); + } + } + + private static FailureMechanismAssemblyCategoryGroupControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyCategoryGroupControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private PipingStructureResultViewOld ShowFailureMechanismResultsView( + PipingStructureFailureMechanism failureMechanism) + { + var failureMechanismResultView = new PipingStructureResultViewOld(failureMechanism.SectionResults, + failureMechanism); + testForm.Controls.Add(failureMechanismResultView); + testForm.Show(); + + return failureMechanismResultView; + } + + private static ErrorProvider GetManualAssemblyWarningProvider(FailureMechanismAssemblyCategoryGroupControl control) + { + return TypeUtils.GetField(control, "manualAssemblyWarningProvider"); + } + } +} \ No newline at end of file Fisheye: Tag 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/PipingStructureResultViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/StrengthStabilityLengthwiseConstructionResultViewOldTest.cs =================================================================== diff -u --- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/StrengthStabilityLengthwiseConstructionResultViewOldTest.cs (revision 0) +++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/StrengthStabilityLengthwiseConstructionResultViewOldTest.cs (revision 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b) @@ -0,0 +1,228 @@ +// 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 System.Windows.Forms; +using Core.Common.Util.Reflection; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Riskeer.AssemblyTool.KernelWrapper.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Riskeer.Common.Data.AssemblyTool; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.Controls; +using Riskeer.Common.Forms.TestUtil; +using Riskeer.Common.Forms.Views; +using Riskeer.Common.Primitives; +using Riskeer.Integration.Data.StandAlone; +using Riskeer.Integration.Data.StandAlone.SectionResults; +using Riskeer.Integration.Forms.Views.SectionResultRows; +using Riskeer.Integration.Forms.Views.SectionResultViews; + +namespace Riskeer.Integration.Forms.Test.Views.SectionResultViews +{ + [TestFixture] + public class StrengthStabilityLengthwiseConstructionResultViewOldTest + { + private const int nameColumnIndex = 0; + private const int simpleAssessmentResultIndex = 1; + private const int tailorMadeAssessmentResultIndex = 2; + private const int simpleAssemblyCategoryGroupIndex = 3; + private const int tailorMadeAssemblyCategoryGroupIndex = 4; + private const int combinedAssemblyCategoryGroupIndex = 5; + private const int useManualAssemblyIndex = 6; + private const int manualAssemblyCategoryGroupIndex = 7; + private const int columnCount = 8; + + private Form testForm; + + [SetUp] + public void Setup() + { + testForm = new Form(); + } + + [TearDown] + public void TearDown() + { + testForm.Dispose(); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var failureMechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism(); + + // Call + using (var view = new StrengthStabilityLengthwiseConstructionResultViewOld(failureMechanism.SectionResults, failureMechanism)) + { + // Assert + Assert.IsInstanceOf>(view); + Assert.IsNull(view.Data); + Assert.AreSame(failureMechanism, view.FailureMechanism); + } + } + + [Test] + public void GivenFormWithFailureMechanismResultView_ThenExpectedColumnsAreAdded() + { + // Given + using (ShowFailureMechanismResultsView(new StrengthStabilityLengthwiseConstructionFailureMechanism())) + { + // Then + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + Assert.IsInstanceOf(dataGridView.Columns[nameColumnIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[combinedAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[useManualAssemblyIndex]); + Assert.IsInstanceOf(dataGridView.Columns[manualAssemblyCategoryGroupIndex]); + + Assert.AreEqual("Vak", dataGridView.Columns[nameColumnIndex].HeaderText); + Assert.AreEqual("Eenvoudige toets", dataGridView.Columns[simpleAssessmentResultIndex].HeaderText); + Assert.AreEqual("Toets op maat", dataGridView.Columns[tailorMadeAssessmentResultIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\neenvoudige toets", dataGridView.Columns[simpleAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ntoets op maat", dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ngecombineerd", dataGridView.Columns[combinedAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Overschrijf\r\ntoetsoordeel", dataGridView.Columns[useManualAssemblyIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\nhandmatig", dataGridView.Columns[manualAssemblyCategoryGroupIndex].HeaderText); + + Assert.IsTrue(dataGridView.Columns[nameColumnIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[simpleAssessmentResultIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[tailorMadeAssessmentResultIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[simpleAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[combinedAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[useManualAssemblyIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[manualAssemblyCategoryGroupIndex].ReadOnly); + + Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); + Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); + } + } + + [Test] + public void FailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized() + { + // Setup + var failureMechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1") + }); + + // Call + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Assert + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + DataGridViewRowCollection rows = dataGridView.Rows; + Assert.AreEqual(1, rows.Count); + + DataGridViewCellCollection cells = rows[0].Cells; + Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue); + Assert.AreEqual(SimpleAssessmentResultType.None, cells[simpleAssessmentResultIndex].Value); + Assert.AreEqual(TailorMadeAssessmentResultType.None, cells[tailorMadeAssessmentResultIndex].Value); + Assert.AreEqual("Iv", cells[simpleAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[tailorMadeAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[combinedAssemblyCategoryGroupIndex].Value); + Assert.AreEqual(false, cells[useManualAssemblyIndex].Value); + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroup.None, cells[manualAssemblyCategoryGroupIndex].Value); + } + } + + [Test] + public void GivenFailureMechanismResultsViewWithManualAssembly_WhenShown_ThenManualAssemblyUsed() + { + // Given + var failureMechanism = new StrengthStabilityLengthwiseConstructionFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }); + + StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultOld sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.ManualAssemblyCategoryGroup = ManualFailureMechanismSectionAssemblyCategoryGroup.Iv; + sectionResult.UseManualAssembly = true; + + // When + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + // Then + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroupConverter.Convert(sectionResult.ManualAssemblyCategoryGroup), + calculator.FailureMechanismSectionCategories.Single()); + } + } + + [TestFixture] + public class StrengthStabilityLengthwiseConstructionFailureMechanismResultControlTest : FailureMechanismAssemblyCategoryGroupControlTestFixture< + StrengthStabilityLengthwiseConstructionResultViewOld, + StrengthStabilityLengthwiseConstructionFailureMechanism, + StrengthStabilityLengthwiseConstructionFailureMechanismSectionResultOld, + StrengthStabilityLengthwiseConstructionSectionResultRowOld> + { + protected override StrengthStabilityLengthwiseConstructionResultViewOld CreateResultView(StrengthStabilityLengthwiseConstructionFailureMechanism failureMechanism) + { + return new StrengthStabilityLengthwiseConstructionResultViewOld(failureMechanism.SectionResults, + failureMechanism); + } + } + + private static FailureMechanismAssemblyCategoryGroupControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyCategoryGroupControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private StrengthStabilityLengthwiseConstructionResultViewOld ShowFailureMechanismResultsView( + StrengthStabilityLengthwiseConstructionFailureMechanism failureMechanism) + { + var failureMechanismResultView = new StrengthStabilityLengthwiseConstructionResultViewOld(failureMechanism.SectionResults, + failureMechanism); + testForm.Controls.Add(failureMechanismResultView); + testForm.Show(); + + return failureMechanismResultView; + } + + private static ErrorProvider GetManualAssemblyWarningProvider(FailureMechanismAssemblyCategoryGroupControl control) + { + return TypeUtils.GetField(control, "manualAssemblyWarningProvider"); + } + } +} \ No newline at end of file Fisheye: Tag 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/StrengthStabilityLengthwiseConstructionResultViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/TechnicalInnovationResultViewOldTest.cs =================================================================== diff -u --- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/TechnicalInnovationResultViewOldTest.cs (revision 0) +++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/TechnicalInnovationResultViewOldTest.cs (revision 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b) @@ -0,0 +1,228 @@ +// 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 System.Windows.Forms; +using Core.Common.Util.Reflection; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Riskeer.AssemblyTool.KernelWrapper.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Riskeer.Common.Data.AssemblyTool; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.Controls; +using Riskeer.Common.Forms.TestUtil; +using Riskeer.Common.Forms.Views; +using Riskeer.Common.Primitives; +using Riskeer.Integration.Data.StandAlone; +using Riskeer.Integration.Data.StandAlone.SectionResults; +using Riskeer.Integration.Forms.Views.SectionResultRows; +using Riskeer.Integration.Forms.Views.SectionResultViews; + +namespace Riskeer.Integration.Forms.Test.Views.SectionResultViews +{ + [TestFixture] + public class TechnicalInnovationResultViewOldTest + { + private const int nameColumnIndex = 0; + private const int simpleAssessmentResultIndex = 1; + private const int tailorMadeAssessmentResultIndex = 2; + private const int simpleAssemblyCategoryGroupIndex = 3; + private const int tailorMadeAssemblyCategoryGroupIndex = 4; + private const int combinedAssemblyCategoryGroupIndex = 5; + private const int useManualAssemblyIndex = 6; + private const int manualAssemblyCategoryGroupIndex = 7; + private const int columnCount = 8; + + private Form testForm; + + [SetUp] + public void Setup() + { + testForm = new Form(); + } + + [TearDown] + public void TearDown() + { + testForm.Dispose(); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var failureMechanism = new TechnicalInnovationFailureMechanism(); + + // Call + using (var view = new TechnicalInnovationResultViewOld(failureMechanism.SectionResults, failureMechanism)) + { + // Assert + Assert.IsInstanceOf>(view); + Assert.IsNull(view.Data); + Assert.AreSame(failureMechanism, view.FailureMechanism); + } + } + + [Test] + public void GivenFormWithFailureMechanismResultView_ThenExpectedColumnsAreAdded() + { + // Given + using (ShowFailureMechanismResultsView(new TechnicalInnovationFailureMechanism())) + { + // Then + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + Assert.IsInstanceOf(dataGridView.Columns[nameColumnIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[combinedAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[useManualAssemblyIndex]); + Assert.IsInstanceOf(dataGridView.Columns[manualAssemblyCategoryGroupIndex]); + + Assert.AreEqual("Vak", dataGridView.Columns[nameColumnIndex].HeaderText); + Assert.AreEqual("Eenvoudige toets", dataGridView.Columns[simpleAssessmentResultIndex].HeaderText); + Assert.AreEqual("Toets op maat", dataGridView.Columns[tailorMadeAssessmentResultIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\neenvoudige toets", dataGridView.Columns[simpleAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ntoets op maat", dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ngecombineerd", dataGridView.Columns[combinedAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Overschrijf\r\ntoetsoordeel", dataGridView.Columns[useManualAssemblyIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\nhandmatig", dataGridView.Columns[manualAssemblyCategoryGroupIndex].HeaderText); + + Assert.IsTrue(dataGridView.Columns[nameColumnIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[simpleAssessmentResultIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[tailorMadeAssessmentResultIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[simpleAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[combinedAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[useManualAssemblyIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[manualAssemblyCategoryGroupIndex].ReadOnly); + + Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); + Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); + } + } + + [Test] + public void FailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized() + { + // Setup + var failureMechanism = new TechnicalInnovationFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1") + }); + + // Call + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Assert + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + DataGridViewRowCollection rows = dataGridView.Rows; + Assert.AreEqual(1, rows.Count); + + DataGridViewCellCollection cells = rows[0].Cells; + Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue); + Assert.AreEqual(SimpleAssessmentResultType.None, cells[simpleAssessmentResultIndex].Value); + Assert.AreEqual(TailorMadeAssessmentResultType.None, cells[tailorMadeAssessmentResultIndex].Value); + Assert.AreEqual("Iv", cells[simpleAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[tailorMadeAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[combinedAssemblyCategoryGroupIndex].Value); + Assert.AreEqual(false, cells[useManualAssemblyIndex].Value); + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroup.None, cells[manualAssemblyCategoryGroupIndex].Value); + } + } + + [Test] + public void GivenFailureMechanismResultsViewWithManualAssembly_WhenShown_ThenManualAssemblyUsed() + { + // Given + var failureMechanism = new TechnicalInnovationFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }); + + TechnicalInnovationFailureMechanismSectionResultOld sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.ManualAssemblyCategoryGroup = ManualFailureMechanismSectionAssemblyCategoryGroup.Iv; + sectionResult.UseManualAssembly = true; + + // When + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + // Then + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroupConverter.Convert(sectionResult.ManualAssemblyCategoryGroup), + calculator.FailureMechanismSectionCategories.Single()); + } + } + + [TestFixture] + public class TechnicalInnovationFailureMechanismResultControlTest : FailureMechanismAssemblyCategoryGroupControlTestFixture< + TechnicalInnovationResultViewOld, + TechnicalInnovationFailureMechanism, + TechnicalInnovationFailureMechanismSectionResultOld, + TechnicalInnovationSectionResultRowOld> + { + protected override TechnicalInnovationResultViewOld CreateResultView(TechnicalInnovationFailureMechanism failureMechanism) + { + return new TechnicalInnovationResultViewOld(failureMechanism.SectionResults, + failureMechanism); + } + } + + private static FailureMechanismAssemblyCategoryGroupControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyCategoryGroupControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private TechnicalInnovationResultViewOld ShowFailureMechanismResultsView( + TechnicalInnovationFailureMechanism failureMechanism) + { + var failureMechanismResultView = new TechnicalInnovationResultViewOld(failureMechanism.SectionResults, + failureMechanism); + testForm.Controls.Add(failureMechanismResultView); + testForm.Show(); + + return failureMechanismResultView; + } + + private static ErrorProvider GetManualAssemblyWarningProvider(FailureMechanismAssemblyCategoryGroupControl control) + { + return TypeUtils.GetField(control, "manualAssemblyWarningProvider"); + } + } +} \ No newline at end of file Fisheye: Tag 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/TechnicalInnovationResultViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/WaterPressureAsphaltCoverResultViewOldTest.cs =================================================================== diff -u --- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/WaterPressureAsphaltCoverResultViewOldTest.cs (revision 0) +++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/WaterPressureAsphaltCoverResultViewOldTest.cs (revision 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b) @@ -0,0 +1,228 @@ +// 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 System.Windows.Forms; +using Core.Common.Util.Reflection; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Riskeer.AssemblyTool.KernelWrapper.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Riskeer.Common.Data.AssemblyTool; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.Controls; +using Riskeer.Common.Forms.TestUtil; +using Riskeer.Common.Forms.Views; +using Riskeer.Common.Primitives; +using Riskeer.Integration.Data.StandAlone; +using Riskeer.Integration.Data.StandAlone.SectionResults; +using Riskeer.Integration.Forms.Views.SectionResultRows; +using Riskeer.Integration.Forms.Views.SectionResultViews; + +namespace Riskeer.Integration.Forms.Test.Views.SectionResultViews +{ + [TestFixture] + public class WaterPressureAsphaltCoverResultViewOldTest + { + private const int nameColumnIndex = 0; + private const int simpleAssessmentResultIndex = 1; + private const int tailorMadeAssessmentResultIndex = 2; + private const int simpleAssemblyCategoryGroupIndex = 3; + private const int tailorMadeAssemblyCategoryGroupIndex = 4; + private const int combinedAssemblyCategoryGroupIndex = 5; + private const int useManualAssemblyIndex = 6; + private const int manualAssemblyCategoryGroupIndex = 7; + private const int columnCount = 8; + + private Form testForm; + + [SetUp] + public void Setup() + { + testForm = new Form(); + } + + [TearDown] + public void TearDown() + { + testForm.Dispose(); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); + + // Call + using (var view = new WaterPressureAsphaltCoverResultViewOld(failureMechanism.SectionResults, failureMechanism)) + { + // Assert + Assert.IsInstanceOf>(view); + Assert.IsNull(view.Data); + Assert.AreSame(failureMechanism, view.FailureMechanism); + } + } + + [Test] + public void GivenFormWithFailureMechanismResultView_ThenExpectedColumnsAreAdded() + { + // Given + using (ShowFailureMechanismResultsView(new WaterPressureAsphaltCoverFailureMechanism())) + { + // Then + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + Assert.IsInstanceOf(dataGridView.Columns[nameColumnIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssessmentResultIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[combinedAssemblyCategoryGroupIndex]); + Assert.IsInstanceOf(dataGridView.Columns[useManualAssemblyIndex]); + Assert.IsInstanceOf(dataGridView.Columns[manualAssemblyCategoryGroupIndex]); + + Assert.AreEqual("Vak", dataGridView.Columns[nameColumnIndex].HeaderText); + Assert.AreEqual("Eenvoudige toets", dataGridView.Columns[simpleAssessmentResultIndex].HeaderText); + Assert.AreEqual("Toets op maat", dataGridView.Columns[tailorMadeAssessmentResultIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\neenvoudige toets", dataGridView.Columns[simpleAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ntoets op maat", dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\ngecombineerd", dataGridView.Columns[combinedAssemblyCategoryGroupIndex].HeaderText); + Assert.AreEqual("Overschrijf\r\ntoetsoordeel", dataGridView.Columns[useManualAssemblyIndex].HeaderText); + Assert.AreEqual("Toetsoordeel\r\nhandmatig", dataGridView.Columns[manualAssemblyCategoryGroupIndex].HeaderText); + + Assert.IsTrue(dataGridView.Columns[nameColumnIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[simpleAssessmentResultIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[tailorMadeAssessmentResultIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[simpleAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[tailorMadeAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsTrue(dataGridView.Columns[combinedAssemblyCategoryGroupIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[useManualAssemblyIndex].ReadOnly); + Assert.IsFalse(dataGridView.Columns[manualAssemblyCategoryGroupIndex].ReadOnly); + + Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); + Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); + } + } + + [Test] + public void FailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized() + { + // Setup + var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1") + }); + + // Call + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + + // Assert + Assert.AreEqual(columnCount, dataGridView.ColumnCount); + + DataGridViewRowCollection rows = dataGridView.Rows; + Assert.AreEqual(1, rows.Count); + + DataGridViewCellCollection cells = rows[0].Cells; + Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue); + Assert.AreEqual(SimpleAssessmentResultType.None, cells[simpleAssessmentResultIndex].Value); + Assert.AreEqual(TailorMadeAssessmentResultType.None, cells[tailorMadeAssessmentResultIndex].Value); + Assert.AreEqual("Iv", cells[simpleAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[tailorMadeAssemblyCategoryGroupIndex].Value); + Assert.AreEqual("IIv", cells[combinedAssemblyCategoryGroupIndex].Value); + Assert.AreEqual(false, cells[useManualAssemblyIndex].Value); + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroup.None, cells[manualAssemblyCategoryGroupIndex].Value); + } + } + + [Test] + public void GivenFailureMechanismResultsViewWithManualAssembly_WhenShown_ThenManualAssemblyUsed() + { + // Given + var failureMechanism = new WaterPressureAsphaltCoverFailureMechanism(); + FailureMechanismTestHelper.SetSections(failureMechanism, new[] + { + FailureMechanismSectionTestFactory.CreateFailureMechanismSection() + }); + + WaterPressureAsphaltCoverFailureMechanismSectionResultOld sectionResult = failureMechanism.SectionResults.Single(); + sectionResult.ManualAssemblyCategoryGroup = ManualFailureMechanismSectionAssemblyCategoryGroup.Iv; + sectionResult.UseManualAssembly = true; + + // When + using (new AssemblyToolCalculatorFactoryConfig()) + using (ShowFailureMechanismResultsView(failureMechanism)) + { + // Then + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + FailureMechanismAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismAssemblyCalculator; + Assert.AreEqual(ManualFailureMechanismSectionAssemblyCategoryGroupConverter.Convert(sectionResult.ManualAssemblyCategoryGroup), + calculator.FailureMechanismSectionCategories.Single()); + } + } + + [TestFixture] + public class WaterPressureAsphaltCoverFailureMechanismResultControlTest : FailureMechanismAssemblyCategoryGroupControlTestFixture< + WaterPressureAsphaltCoverResultViewOld, + WaterPressureAsphaltCoverFailureMechanism, + WaterPressureAsphaltCoverFailureMechanismSectionResultOld, + WaterPressureAsphaltCoverSectionResultRowOld> + { + protected override WaterPressureAsphaltCoverResultViewOld CreateResultView(WaterPressureAsphaltCoverFailureMechanism failureMechanism) + { + return new WaterPressureAsphaltCoverResultViewOld(failureMechanism.SectionResults, + failureMechanism); + } + } + + private static FailureMechanismAssemblyCategoryGroupControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyCategoryGroupControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private WaterPressureAsphaltCoverResultViewOld ShowFailureMechanismResultsView( + WaterPressureAsphaltCoverFailureMechanism failureMechanism) + { + var failureMechanismResultView = new WaterPressureAsphaltCoverResultViewOld(failureMechanism.SectionResults, + failureMechanism); + testForm.Controls.Add(failureMechanismResultView); + testForm.Show(); + + return failureMechanismResultView; + } + + private static ErrorProvider GetManualAssemblyWarningProvider(FailureMechanismAssemblyCategoryGroupControl control) + { + return TypeUtils.GetField(control, "manualAssemblyWarningProvider"); + } + } +} \ No newline at end of file Fisheye: Tag 7f7cc7d0fe4418264df0af7ce94e4e9e793df53b refers to a dead (removed) revision in file `Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/SectionResultViews/WaterPressureAsphaltCoverResultViewTest.cs'. Fisheye: No comparison available. Pass `N' to diff?