Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs =================================================================== diff -u -rca0cf77c91b38a4361e96fb95d431eb7c9984501 -r80cc77ed4382e822d305dbef5b8ac604d61ea02a --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs) (revision ca0cf77c91b38a4361e96fb95d431eb7c9984501) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs) (revision 80cc77ed4382e822d305dbef5b8ac604d61ea02a) @@ -66,30 +66,28 @@ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); using (var form = new Form()) + using (var view = new GrassCoverErosionOutwardsFailureMechanismResultView(failureMechanism.SectionResults, failureMechanism)) { - using (var view = new GrassCoverErosionOutwardsFailureMechanismResultView(failureMechanism.SectionResults, failureMechanism)) - { - form.Controls.Add(view); + form.Controls.Add(view); - // When - form.Show(); + // When + form.Show(); - // Then - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + // Then + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - Assert.AreEqual(4, dataGridView.ColumnCount); + Assert.AreEqual(4, dataGridView.ColumnCount); - Assert.IsInstanceOf(dataGridView.Columns[simpleAssessmentIndex]); - Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerTwoAIndex]); - Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerThreeIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssessmentIndex]); + Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerTwoAIndex]); + Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerThreeIndex]); - Assert.AreEqual("Eenvoudige toets", dataGridView.Columns[simpleAssessmentIndex].HeaderText); - Assert.AreEqual("Gedetailleerde toets per vak", dataGridView.Columns[assessmentLayerTwoAIndex].HeaderText); - Assert.AreEqual("Toets op maat", dataGridView.Columns[assessmentLayerThreeIndex].HeaderText); + Assert.AreEqual("Eenvoudige toets", dataGridView.Columns[simpleAssessmentIndex].HeaderText); + Assert.AreEqual("Gedetailleerde toets per vak", dataGridView.Columns[assessmentLayerTwoAIndex].HeaderText); + Assert.AreEqual("Toets op maat", dataGridView.Columns[assessmentLayerThreeIndex].HeaderText); - Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); - Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); - } + Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); + Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); } } @@ -225,27 +223,25 @@ }; using (var form = new Form()) + using (var view = new GrassCoverErosionOutwardsFailureMechanismResultView(sectionResults, new GrassCoverErosionOutwardsFailureMechanism())) { - using (var view = new GrassCoverErosionOutwardsFailureMechanismResultView(sectionResults, new GrassCoverErosionOutwardsFailureMechanism())) - { - form.Controls.Add(view); - form.Show(); + form.Controls.Add(view); + form.Show(); - // When - result.SimpleAssessmentResult = SimpleAssessmentResultType.ProbabilityNegligible; - result.NotifyObservers(); + // When + result.SimpleAssessmentResult = SimpleAssessmentResultType.ProbabilityNegligible; + result.NotifyObservers(); - // Then - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - DataGridViewRowCollection rows = dataGridView.Rows; - Assert.AreEqual(1, rows.Count); + // Then + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + DataGridViewRowCollection rows = dataGridView.Rows; + Assert.AreEqual(1, rows.Count); - DataGridViewCellCollection cells = rows[0].Cells; - Assert.AreEqual(4, cells.Count); + DataGridViewCellCollection cells = rows[0].Cells; + Assert.AreEqual(4, cells.Count); - DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); - DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); - } + DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); + DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); } } } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresFailureMechanismResultViewInfoTest.cs =================================================================== diff -u -r33ce6fa967e380d4c68bd5f53acc189ab7f1e726 -r80cc77ed4382e822d305dbef5b8ac604d61ea02a --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresFailureMechanismResultViewInfoTest.cs (.../HeightStructuresFailureMechanismResultViewInfoTest.cs) (revision 33ce6fa967e380d4c68bd5f53acc189ab7f1e726) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresFailureMechanismResultViewInfoTest.cs (.../HeightStructuresFailureMechanismResultViewInfoTest.cs) (revision 80cc77ed4382e822d305dbef5b8ac604d61ea02a) @@ -30,7 +30,6 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; -using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.HeightStructures.Data; Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj =================================================================== diff -u -r94f68f51cd9b8fd8c0c162cf874ef7e4580b0ee4 -r80cc77ed4382e822d305dbef5b8ac604d61ea02a --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 94f68f51cd9b8fd8c0c162cf874ef7e4580b0ee4) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 80cc77ed4382e822d305dbef5b8ac604d61ea02a) @@ -99,7 +99,7 @@ - + Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismViewInfoTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismViewInfoTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismViewInfoTest.cs (revision 80cc77ed4382e822d305dbef5b8ac604d61ea02a) @@ -0,0 +1,217 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Linq; +using Core.Common.Gui.Plugin; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.PresentationObjects; +using Ringtoets.Common.Forms.Views; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.Integration.Plugin.Test.ViewInfos +{ + [TestFixture] + public class FailureMechanismViewInfoTest + { + private MockRepository mocks; + private RingtoetsPlugin plugin; + private ViewInfo info; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + plugin = new RingtoetsPlugin(); + info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(FailureMechanismView)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(IFailureMechanismContext), info.DataType); + Assert.AreEqual(typeof(IFailureMechanismContext), info.ViewDataType); + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculationIcon, info.Image); + } + + [Test] + public void GetViewName_WithTestFailureMechanism_ReturnsNameOfFailureMechanism() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new TestFailureMechanism(); + var failureMechanismContext = new TestFailureMechanismContext(failureMechanism, assessmentSection); + + using (var view = new FailureMechanismView()) + { + // Call + string viewName = info.GetViewName(view, failureMechanismContext); + + // Assert + Assert.AreEqual(failureMechanism.Name, viewName); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() + { + // Setup + var assessmentSection = new ObservableTestAssessmentSectionStub(); + var otherAssessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new TestFailureMechanism(); + var failureMechanismContext = new TestFailureMechanismContext(failureMechanism, assessmentSection); + + using (var view = new FailureMechanismView + { + Data = failureMechanismContext + }) + { + // Call + bool closeForData = info.CloseForData(view, otherAssessmentSection); + + // Assert + Assert.IsFalse(closeForData); + } + + mocks.VerifyAll(); + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue() + { + // Setup + var assessmentSection = new ObservableTestAssessmentSectionStub(); + + var failureMechanism = new TestFailureMechanism(); + var failureMechanismContext = new TestFailureMechanismContext(failureMechanism, assessmentSection); + + using (var view = new FailureMechanismView + { + Data = failureMechanismContext + }) + { + // Call + bool closeForData = info.CloseForData(view, assessmentSection); + + // Assert + Assert.IsTrue(closeForData); + } + } + + [Test] + public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse() + { + // Setup + var assessmentSection = new ObservableTestAssessmentSectionStub(); + + var failureMechanism = new TestFailureMechanism(); + var otherTestFailureMechanism = new TestFailureMechanism(); + + var failureMechanismContext = new TestFailureMechanismContext(failureMechanism, assessmentSection); + + using (var view = new FailureMechanismView + { + Data = failureMechanismContext + }) + { + // Call + bool closeForData = info.CloseForData(view, otherTestFailureMechanism); + + // Assert + Assert.IsFalse(closeForData); + } + } + + [Test] + public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue() + { + // Setup + var assessmentSection = new ObservableTestAssessmentSectionStub(); + + var failureMechanism = new TestFailureMechanism(); + var failureMechanismContext = new TestFailureMechanismContext(failureMechanism, assessmentSection); + + using (var view = new FailureMechanismView + { + Data = failureMechanismContext + }) + { + // Call + bool closeForData = info.CloseForData(view, failureMechanism); + + // Assert + Assert.IsTrue(closeForData); + } + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void AdditionalDataCheck_Always_ReturnTrueOnlyIfFailureMechanismRelevant(bool isRelevant) + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new TestFailureMechanism + { + IsRelevant = isRelevant + }; + + var context = new TestFailureMechanismContext(failureMechanism, assessmentSection); + + // Call + bool result = info.AdditionalDataCheck(context); + + // Assert + Assert.AreEqual(isRelevant, result); + mocks.VerifyAll(); + } + + private class TestFailureMechanismContext : IFailureMechanismContext + { + public TestFailureMechanismContext(IFailureMechanism wrappedData, IAssessmentSection parent) + { + WrappedData = wrappedData; + Parent = parent; + } + + public IFailureMechanism WrappedData { get; } + + public IAssessmentSection Parent { get; } + } + } +} \ No newline at end of file Fisheye: Tag 80cc77ed4382e822d305dbef5b8ac604d61ea02a refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/TestFailureMechanismViewInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff?