Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsFailureMechanismViewInfoTest.cs =================================================================== diff -u -rf07d6418a5280c74ea8a35de183dbaed51dda066 -r6f33b44599df032ecae3342b0aacd606a9e87c1f --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsFailureMechanismViewInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismViewInfoTest.cs) (revision f07d6418a5280c74ea8a35de183dbaed51dda066) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsFailureMechanismViewInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismViewInfoTest.cs) (revision 6f33b44599df032ecae3342b0aacd606a9e87c1f) @@ -19,7 +19,9 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Drawing; using System.Linq; +using Core.Common.Controls.Views; using Core.Common.Gui.Plugin; using Core.Common.TestUtil; using NUnit.Framework; @@ -60,7 +62,6 @@ // Assert Assert.AreEqual(typeof(GrassCoverErosionInwardsFailureMechanismContext), info.DataType); Assert.AreEqual(typeof(GrassCoverErosionInwardsFailureMechanismContext), info.ViewDataType); - TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculationIcon, info.Image); } [Test] @@ -70,58 +71,57 @@ var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - var grassCoverErosionInwardsFailureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var grassCoverErosionInwardsFailureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(grassCoverErosionInwardsFailureMechanism, assessmentSection); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var grassCoverErosionInwardsFailureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection); - using (var view = new GrassCoverErosionInwardsFailureMechanismView()) - { - // Call - string viewName = info.GetViewName(view, grassCoverErosionInwardsFailureMechanismContext); + // Call + string viewName = info.GetViewName(null, grassCoverErosionInwardsFailureMechanismContext); - // Assert - Assert.AreEqual(grassCoverErosionInwardsFailureMechanism.Name, viewName); - } + // Assert + Assert.AreEqual(failureMechanism.Name, viewName); } [Test] + public void Image_Always_ReturnsGenericInputOutputIcon() + { + // Call + Image image = info.Image; + + // Assert + TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculationIcon, image); + } + + [Test] public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse() { // Setup - var assessmentSection = new ObservableTestAssessmentSectionStub(); + var assessmentSection = new AssessmentSectionStub(); var otherAssessmentSection = mocks.Stub(); mocks.ReplayAll(); - var grassCoverErosionInwardsFailureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var grassCoverErosionInwardsFailureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(grassCoverErosionInwardsFailureMechanism, assessmentSection); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - using (var view = new GrassCoverErosionInwardsFailureMechanismView + using (var view = new GrassCoverErosionInwardsFailureMechanismView(failureMechanism, assessmentSection)) { - Data = grassCoverErosionInwardsFailureMechanismContext - }) - { // 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 assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var grassCoverErosionInwardsFailureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var grassCoverErosionInwardsFailureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(grassCoverErosionInwardsFailureMechanism, assessmentSection); - - using (var view = new GrassCoverErosionInwardsFailureMechanismView + using (var view = new GrassCoverErosionInwardsFailureMechanismView(failureMechanism, assessmentSection)) { - Data = grassCoverErosionInwardsFailureMechanismContext - }) - { // Call bool closeForData = info.CloseForData(view, assessmentSection); @@ -134,19 +134,14 @@ public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse() { // Setup - var assessmentSection = new ObservableTestAssessmentSectionStub(); + var assessmentSection = new AssessmentSectionStub(); mocks.ReplayAll(); - var grassCoverErosionInwardsFailureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var otherGrassCoverErosionInwardsFailureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var grassCoverErosionInwardsFailureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(grassCoverErosionInwardsFailureMechanism, assessmentSection); - - using (var view = new GrassCoverErosionInwardsFailureMechanismView + using (var view = new GrassCoverErosionInwardsFailureMechanismView(failureMechanism, assessmentSection)) { - Data = grassCoverErosionInwardsFailureMechanismContext - }) - { // Call bool closeForData = info.CloseForData(view, otherGrassCoverErosionInwardsFailureMechanism); @@ -159,18 +154,13 @@ public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue() { // Setup - var assessmentSection = new ObservableTestAssessmentSectionStub(); + var assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var grassCoverErosionInwardsFailureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var grassCoverErosionInwardsFailureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(grassCoverErosionInwardsFailureMechanism, assessmentSection); - - using (var view = new GrassCoverErosionInwardsFailureMechanismView + using (var view = new GrassCoverErosionInwardsFailureMechanismView(failureMechanism, assessmentSection)) { - Data = grassCoverErosionInwardsFailureMechanismContext - }) - { // Call - bool closeForData = info.CloseForData(view, grassCoverErosionInwardsFailureMechanism); + bool closeForData = info.CloseForData(view, failureMechanism); // Assert Assert.IsTrue(closeForData); @@ -200,5 +190,21 @@ Assert.AreEqual(isRelevant, result); mocks.VerifyAll(); } + + [Test] + public void CreateInstance_WithContext_ReturnGrassCoverErosionInwardsFailureMechanismView() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + var context = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection); + + // Call + IView view = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(view); + } } } \ No newline at end of file