Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/DesignWaterLevelLocationsContext.cs =================================================================== diff -u -r802ea30d1fe8fbae93e58dff9ab054dbabca11ae -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/DesignWaterLevelLocationsContext.cs (.../DesignWaterLevelLocationsContext.cs) (revision 802ea30d1fe8fbae93e58dff9ab054dbabca11ae) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/DesignWaterLevelLocationsContext.cs (.../DesignWaterLevelLocationsContext.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using Core.Common.Base; using Core.Common.Controls.PresentationObjects; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; @@ -30,13 +31,28 @@ /// Presentation object for all data required to configure an enumeration of /// with . /// - public class DesignWaterLevelLocationsContext : ObservableWrappedObjectContextBase + public class DesignWaterLevelLocationsContext : ObservableWrappedObjectContextBase> { /// /// Creates a new instance of . /// - /// The which the belongs to. - /// Thrown when is null. - public DesignWaterLevelLocationsContext(IAssessmentSection wrappedAssessmentSection) : base(wrappedAssessmentSection) {} + /// The locations that the belongs to. + /// The that the belongs to. + /// Thrown when any parameter is null. + public DesignWaterLevelLocationsContext(ObservableList wrappedData, + IAssessmentSection assessmentSection) : base(wrappedData) + { + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + AssessmentSection = assessmentSection; + } + + /// + /// Gets the assessment section that the context belongs to. + /// + public IAssessmentSection AssessmentSection { get; } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/HydraulicBoundaryDatabaseContext.cs =================================================================== diff -u -r802ea30d1fe8fbae93e58dff9ab054dbabca11ae -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/HydraulicBoundaryDatabaseContext.cs (.../HydraulicBoundaryDatabaseContext.cs) (revision 802ea30d1fe8fbae93e58dff9ab054dbabca11ae) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/HydraulicBoundaryDatabaseContext.cs (.../HydraulicBoundaryDatabaseContext.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -30,13 +30,27 @@ /// /// Presentation object for all data required to configure an instance of . /// - public class HydraulicBoundaryDatabaseContext : ObservableWrappedObjectContextBase + public class HydraulicBoundaryDatabaseContext : ObservableWrappedObjectContextBase { /// /// Creates a new instance of . /// - /// The which the belongs to. - /// Thrown when is null. - public HydraulicBoundaryDatabaseContext(AssessmentSection wrappedAssessmentSection) : base(wrappedAssessmentSection) {} + /// The that the belongs to. + /// The that the belongs to. + /// Thrown when any parameter is null. + public HydraulicBoundaryDatabaseContext(HydraulicBoundaryDatabase wrappedData, + AssessmentSection assessmentSection) : base(wrappedData) + { + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + AssessmentSection = assessmentSection; + } + + /// + /// Gets the assessment section that the context belongs to. + /// + public AssessmentSection AssessmentSection { get; } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/WaveHeightLocationsContext.cs =================================================================== diff -u -r802ea30d1fe8fbae93e58dff9ab054dbabca11ae -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/WaveHeightLocationsContext.cs (.../WaveHeightLocationsContext.cs) (revision 802ea30d1fe8fbae93e58dff9ab054dbabca11ae) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PresentationObjects/WaveHeightLocationsContext.cs (.../WaveHeightLocationsContext.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using Core.Common.Base; using Core.Common.Controls.PresentationObjects; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; @@ -30,13 +31,28 @@ /// Presentation object for all data required to configure an enumeration of /// with . /// - public class WaveHeightLocationsContext : ObservableWrappedObjectContextBase + public class WaveHeightLocationsContext : ObservableWrappedObjectContextBase> { /// /// Creates a new instance of . /// - /// The which the belongs to. - /// Thrown when is null. - public WaveHeightLocationsContext(IAssessmentSection wrappedAssessmentSection) : base(wrappedAssessmentSection) {} + /// The locations that the belongs to. + /// The that the belongs to. + /// Thrown when any parameter is null. + public WaveHeightLocationsContext(ObservableList wrappedData, + IAssessmentSection assessmentSection) : base(wrappedData) + { + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + AssessmentSection = assessmentSection; + } + + /// + /// Gets the assessment section that the context belongs to. + /// + public IAssessmentSection AssessmentSection { get; } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryDatabaseProperties.cs =================================================================== diff -u -r0d495f2706215f1b75da521c905eb6105f2f8a34 -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryDatabaseProperties.cs (.../HydraulicBoundaryDatabaseProperties.cs) (revision 0d495f2706215f1b75da521c905eb6105f2f8a34) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryDatabaseProperties.cs (.../HydraulicBoundaryDatabaseProperties.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -27,7 +27,6 @@ using Core.Common.Gui.PropertyBag; using Core.Common.Util.Attributes; using Ringtoets.Common.Data.Hydraulics; -using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.Properties; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -36,22 +35,22 @@ /// /// ViewModel of for properties panel. /// - public class HydraulicBoundaryDatabaseProperties : ObjectProperties + public class HydraulicBoundaryDatabaseProperties : ObjectProperties { /// /// Creates a new instance of . /// - /// The context to show the properties for. - /// Thrown when + /// The hydraulic boundary database to show the properties for. + /// Thrown when /// is null. - public HydraulicBoundaryDatabaseProperties(HydraulicBoundaryDatabaseContext hydraulicBoundaryDatabaseContext) + public HydraulicBoundaryDatabaseProperties(HydraulicBoundaryDatabase hydraulicBoundaryDatabase) { - if (hydraulicBoundaryDatabaseContext == null) + if (hydraulicBoundaryDatabase == null) { - throw new ArgumentNullException(nameof(hydraulicBoundaryDatabaseContext)); + throw new ArgumentNullException(nameof(hydraulicBoundaryDatabase)); } - Data = hydraulicBoundaryDatabaseContext; + Data = hydraulicBoundaryDatabase; } [PropertyOrder(1)] @@ -62,7 +61,7 @@ { get { - return data.WrappedData.HydraulicBoundaryDatabase.IsLinked() ? data.WrappedData.HydraulicBoundaryDatabase.FilePath : string.Empty; + return data.IsLinked() ? data.FilePath : string.Empty; } } @@ -75,12 +74,12 @@ { get { - return data.WrappedData.HydraulicBoundaryDatabase.UsePreprocessor; + return data.UsePreprocessor; } set { - data.WrappedData.HydraulicBoundaryDatabase.UsePreprocessor = value; - data.WrappedData.NotifyObservers(); + data.UsePreprocessor = value; + data.NotifyObservers(); } } @@ -94,11 +93,11 @@ { get { - return data.WrappedData.HydraulicBoundaryDatabase.PreprocessorDirectory; + return data.PreprocessorDirectory; } set { - data.WrappedData.HydraulicBoundaryDatabase.PreprocessorDirectory = value; + data.PreprocessorDirectory = value; } } @@ -111,14 +110,14 @@ { get { - return data.WrappedData.HydraulicBoundaryDatabase.PreprocessorDirectory; + return data.PreprocessorDirectory; } } [DynamicVisibleValidationMethod] public bool DynamicVisibleValidationMethod(string propertyName) { - bool canUsePreprocessor = data.WrappedData.HydraulicBoundaryDatabase.CanUsePreprocessor; + bool canUsePreprocessor = data.CanUsePreprocessor; if (propertyName.Equals(nameof(UsePreprocessor)) && !canUsePreprocessor) { Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r75d12c89224759df39acf21f187f309a3e4ae274 -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 75d12c89224759df39acf21f187f309a3e4ae274) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -294,7 +294,7 @@ }; yield return new PropertyInfo { - CreateInstance = context => new HydraulicBoundaryDatabaseProperties(context) + CreateInstance = context => new HydraulicBoundaryDatabaseProperties(context.WrappedData) }; yield return new PropertyInfo { @@ -317,7 +317,7 @@ yield return new PropertyInfo { CreateInstance = context => new DesignWaterLevelLocationsProperties( - context.WrappedData.HydraulicBoundaryDatabase.Locations) + context.WrappedData) }; yield return new PropertyInfo { @@ -326,7 +326,7 @@ yield return new PropertyInfo { CreateInstance = context => new WaveHeightLocationsProperties( - context.WrappedData.HydraulicBoundaryDatabase.Locations) + context.WrappedData) }; yield return new PropertyInfo { @@ -379,20 +379,20 @@ yield return new ViewInfo, DesignWaterLevelLocationsView> { GetViewName = (view, context) => RingtoetsFormsResources.DesignWaterLevelLocationsContext_DisplayName, - GetViewData = context => context.WrappedData.HydraulicBoundaryDatabase.Locations, + GetViewData = context => context.WrappedData, Image = RingtoetsCommonFormsResources.GenericInputOutputIcon, CloseForData = CloseHydraulicBoundaryLocationsViewForData, - CreateInstance = context => new DesignWaterLevelLocationsView(context.WrappedData.HydraulicBoundaryDatabase.Locations, context.WrappedData), + CreateInstance = context => new DesignWaterLevelLocationsView(context.WrappedData, context.AssessmentSection), AfterCreate = (view, context) => { view.CalculationGuiService = hydraulicBoundaryLocationCalculationGuiService; } }; yield return new ViewInfo, WaveHeightLocationsView> { GetViewName = (view, context) => RingtoetsFormsResources.WaveHeightLocationsContext_DisplayName, - GetViewData = context => context.WrappedData.HydraulicBoundaryDatabase.Locations, + GetViewData = context => context.WrappedData, Image = RingtoetsCommonFormsResources.GenericInputOutputIcon, CloseForData = CloseHydraulicBoundaryLocationsViewForData, - CreateInstance = context => new WaveHeightLocationsView(context.WrappedData.HydraulicBoundaryDatabase.Locations, context.WrappedData), + CreateInstance = context => new WaveHeightLocationsView(context.WrappedData, context.AssessmentSection), AfterCreate = (view, context) => { view.CalculationGuiService = hydraulicBoundaryLocationCalculationGuiService; } }; @@ -521,9 +521,9 @@ { Name = RingtoetsCommonDataResources.HydraulicBoundaryConditions_DisplayName, CreateFileExporter = (context, filePath) => new HydraulicBoundaryLocationsExporter( - context.WrappedData.HydraulicBoundaryDatabase.Locations, filePath, + context.WrappedData.Locations, filePath, RingtoetsIntegrationPluginResources.DesignWaterLevel_Description, RingtoetsIntegrationPluginResources.WaveHeight_Description), - IsEnabled = context => context.WrappedData.HydraulicBoundaryDatabase.IsLinked(), + IsEnabled = context => context.WrappedData.IsLinked(), FileFilterGenerator = new FileFilterGenerator(RingtoetsCommonIOResources.Shape_file_filter_Extension, RingtoetsCommonIOResources.Shape_file_filter_Description) }; @@ -661,7 +661,7 @@ { Text = hydraulicBoundaryDatabase => RingtoetsFormsResources.HydraulicBoundaryDatabase_DisplayName, Image = hydraulicBoundaryDatabase => RingtoetsCommonFormsResources.GenericInputOutputIcon, - ForeColor = context => context.WrappedData.HydraulicBoundaryDatabase.IsLinked() + ForeColor = context => context.WrappedData.IsLinked() ? Color.FromKnownColor(KnownColor.ControlText) : Color.FromKnownColor(KnownColor.GrayText), ChildNodeObjects = HydraulicBoundaryDatabaseChildNodeObjects, @@ -930,9 +930,9 @@ if (assessmentSection != null) { return assessmentSection - .GetFailureMechanisms() - .OfType>() - .Any(fm => ReferenceEquals(viewData, fm.SectionResults)); + .GetFailureMechanisms() + .OfType>() + .Any(fm => ReferenceEquals(viewData, fm.SectionResults)); } if (failureMechanismContext != null) @@ -1127,7 +1127,7 @@ nodeData.BackgroundData, new ReferenceLineContext(nodeData), new FailureMechanismContributionContext(nodeData.FailureMechanismContribution, nodeData), - new HydraulicBoundaryDatabaseContext(nodeData), + new HydraulicBoundaryDatabaseContext(nodeData.HydraulicBoundaryDatabase, nodeData), nodeData.Comments }; @@ -1140,11 +1140,11 @@ private static IEnumerable WrapFailureMechanismsInContexts(IAssessmentSection assessmentSection) { return assessmentSection - .GetFailureMechanisms() - .Select(failureMechanism => failureMechanismAssociations - .First(a => a.Match(failureMechanism)) - .Create(failureMechanism, assessmentSection)) - .ToArray(); + .GetFailureMechanisms() + .Select(failureMechanism => failureMechanismAssociations + .First(a => a.Match(failureMechanism)) + .Create(failureMechanism, assessmentSection)) + .ToArray(); } private static void AssessmentSectionOnNodeRenamed(IAssessmentSection nodeData, string newName) @@ -1399,12 +1399,14 @@ private static object[] HydraulicBoundaryDatabaseChildNodeObjects(HydraulicBoundaryDatabaseContext nodeData) { - if (nodeData.WrappedData.HydraulicBoundaryDatabase.IsLinked()) + if (nodeData.WrappedData.IsLinked()) { return new object[] { - new DesignWaterLevelLocationsContext(nodeData.WrappedData), - new WaveHeightLocationsContext(nodeData.WrappedData) + new DesignWaterLevelLocationsContext(nodeData.WrappedData.Locations, + nodeData.AssessmentSection), + new WaveHeightLocationsContext(nodeData.WrappedData.Locations, + nodeData.AssessmentSection) }; } @@ -1424,15 +1426,15 @@ return; } - IAssessmentSection assessmentSection = nodeData.WrappedData; + IAssessmentSection assessmentSection = nodeData.AssessmentSection; hydraulicBoundaryLocationCalculationGuiService.CalculateDesignWaterLevels(assessmentSection.HydraulicBoundaryDatabase.FilePath, assessmentSection.HydraulicBoundaryDatabase.EffectivePreprocessorDirectory(), assessmentSection.HydraulicBoundaryDatabase.Locations, assessmentSection.FailureMechanismContribution.Norm, new DesignWaterLevelCalculationMessageProvider()); }); - SetHydraulicsMenuItemEnabledStateAndTooltip(nodeData.WrappedData, designWaterLevelItem); + SetHydraulicsMenuItemEnabledStateAndTooltip(nodeData.AssessmentSection, designWaterLevelItem); return Gui.Get(nodeData, treeViewControl) .AddOpenItem() @@ -1456,15 +1458,15 @@ return; } - IAssessmentSection assessmentSection = nodeData.WrappedData; + IAssessmentSection assessmentSection = nodeData.AssessmentSection; hydraulicBoundaryLocationCalculationGuiService.CalculateWaveHeights(assessmentSection.HydraulicBoundaryDatabase.FilePath, assessmentSection.HydraulicBoundaryDatabase.EffectivePreprocessorDirectory(), assessmentSection.HydraulicBoundaryDatabase.Locations, assessmentSection.FailureMechanismContribution.Norm, new WaveHeightCalculationMessageProvider()); }); - SetHydraulicsMenuItemEnabledStateAndTooltip(nodeData.WrappedData, waveHeightItem); + SetHydraulicsMenuItemEnabledStateAndTooltip(nodeData.AssessmentSection, waveHeightItem); return Gui.Get(nodeData, treeViewControl) .AddOpenItem() @@ -1490,7 +1492,7 @@ var connectionItem = new StrictContextMenuItem( RingtoetsFormsResources.HydraulicBoundaryDatabase_Connect, RingtoetsFormsResources.HydraulicBoundaryDatabase_Connect_ToolTip, - RingtoetsCommonFormsResources.DatabaseIcon, (sender, args) => SelectDatabaseFile(nodeData.WrappedData)); + RingtoetsCommonFormsResources.DatabaseIcon, (sender, args) => SelectDatabaseFile(nodeData.AssessmentSection)); return Gui.Get(nodeData, treeViewControl) .AddCustomItem(connectionItem) Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/DesignWaterLevelLocationsContextTest.cs =================================================================== diff -u -r802ea30d1fe8fbae93e58dff9ab054dbabca11ae -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/DesignWaterLevelLocationsContextTest.cs (.../DesignWaterLevelLocationsContextTest.cs) (revision 802ea30d1fe8fbae93e58dff9ab054dbabca11ae) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/DesignWaterLevelLocationsContextTest.cs (.../DesignWaterLevelLocationsContextTest.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -19,10 +19,13 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.Base; using Core.Common.Controls.PresentationObjects; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Integration.Forms.PresentationObjects; namespace Ringtoets.Integration.Forms.Test.PresentationObjects @@ -31,20 +34,34 @@ public class DesignWaterLevelLocationsContextTest { [Test] - public void DefaultConstructor_ExpectedValues() + public void Constructor_ExpectedValues() { // Setup var mockRepository = new MockRepository(); var assessmentSection = mockRepository.Stub(); mockRepository.ReplayAll(); + var locations = new ObservableList(); + // Call - var presentationObject = new DesignWaterLevelLocationsContext(assessmentSection); + var presentationObject = new DesignWaterLevelLocationsContext(locations, assessmentSection); // Assert - Assert.IsInstanceOf>(presentationObject); - Assert.AreSame(assessmentSection, presentationObject.WrappedData); + Assert.IsInstanceOf>>(presentationObject); + Assert.AreSame(locations, presentationObject.WrappedData); + Assert.AreSame(assessmentSection, presentationObject.AssessmentSection); mockRepository.VerifyAll(); } + + [Test] + public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new DesignWaterLevelLocationsContext(new ObservableList(), null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/HydraulicBoundaryDatabaseContextTest.cs =================================================================== diff -u -r802ea30d1fe8fbae93e58dff9ab054dbabca11ae -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/HydraulicBoundaryDatabaseContextTest.cs (.../HydraulicBoundaryDatabaseContextTest.cs) (revision 802ea30d1fe8fbae93e58dff9ab054dbabca11ae) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/HydraulicBoundaryDatabaseContextTest.cs (.../HydraulicBoundaryDatabaseContextTest.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -19,9 +19,11 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Core.Common.Controls.PresentationObjects; using NUnit.Framework; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Integration.Data; using Ringtoets.Integration.Forms.PresentationObjects; @@ -31,17 +33,29 @@ public class HydraulicBoundaryDatabaseContextTest { [Test] - public void DefaultConstructor_ExpectedValues() + public void Constructor_ExpectedValues() { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); // Call - var presentationObject = new HydraulicBoundaryDatabaseContext(assessmentSection); + var presentationObject = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, assessmentSection); // Assert - Assert.IsInstanceOf>(presentationObject); - Assert.AreSame(assessmentSection, presentationObject.WrappedData); + Assert.IsInstanceOf>(presentationObject); + Assert.AreSame(assessmentSection.HydraulicBoundaryDatabase, presentationObject.WrappedData); + Assert.AreSame(assessmentSection, presentationObject.AssessmentSection); } + + [Test] + public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new HydraulicBoundaryDatabaseContext(new HydraulicBoundaryDatabase(), null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/WaveHeightLocationsContextTest.cs =================================================================== diff -u -r802ea30d1fe8fbae93e58dff9ab054dbabca11ae -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/WaveHeightLocationsContextTest.cs (.../WaveHeightLocationsContextTest.cs) (revision 802ea30d1fe8fbae93e58dff9ab054dbabca11ae) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PresentationObjects/WaveHeightLocationsContextTest.cs (.../WaveHeightLocationsContextTest.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -19,10 +19,13 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.Base; using Core.Common.Controls.PresentationObjects; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Integration.Forms.PresentationObjects; namespace Ringtoets.Integration.Forms.Test.PresentationObjects @@ -31,20 +34,34 @@ public class WaveHeightLocationsContextTest { [Test] - public void DefaultConstructor_ExpectedValues() + public void Constructor_ExpectedValues() { // Setup var mockRepository = new MockRepository(); var assessmentSection = mockRepository.Stub(); mockRepository.ReplayAll(); + var locations = new ObservableList(); + // Call - var presentationObject = new WaveHeightLocationsContext(assessmentSection); + var presentationObject = new WaveHeightLocationsContext(locations, assessmentSection); // Assert - Assert.IsInstanceOf>(presentationObject); - Assert.AreSame(assessmentSection, presentationObject.WrappedData); + Assert.IsInstanceOf>>(presentationObject); + Assert.AreSame(locations, presentationObject.WrappedData); + Assert.AreSame(assessmentSection, presentationObject.AssessmentSection); mockRepository.VerifyAll(); } + + [Test] + public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new WaveHeightLocationsContext(new ObservableList(), null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryDatabasePropertiesTest.cs =================================================================== diff -u -r39e18750ccb61ad1f367279f9dac39a232d4f843 -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryDatabasePropertiesTest.cs (.../HydraulicBoundaryDatabasePropertiesTest.cs) (revision 39e18750ccb61ad1f367279f9dac39a232d4f843) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryDatabasePropertiesTest.cs (.../HydraulicBoundaryDatabasePropertiesTest.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -25,9 +25,7 @@ using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; -using Ringtoets.Common.Data.AssessmentSection; -using Ringtoets.Integration.Data; -using Ringtoets.Integration.Forms.PresentationObjects; +using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Integration.Forms.PropertyClasses; namespace Ringtoets.Integration.Forms.Test.PropertyClasses @@ -43,14 +41,14 @@ public void Constructor_ExpectedValues() { // Setup - var context = new HydraulicBoundaryDatabaseContext(new AssessmentSection(AssessmentSectionComposition.Dike)); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); // Call - var properties = new HydraulicBoundaryDatabaseProperties(context); + var properties = new HydraulicBoundaryDatabaseProperties(hydraulicBoundaryDatabase); // Assert - Assert.IsInstanceOf>(properties); - Assert.AreSame(context, properties.Data); + Assert.IsInstanceOf>(properties); + Assert.AreSame(hydraulicBoundaryDatabase, properties.Data); } [Test] @@ -61,19 +59,16 @@ const bool usePreprocessor = true; const string preprocessorDirectory = @"C:\preprocessor"; - var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(new AssessmentSection(AssessmentSectionComposition.Dike) + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { - HydraulicBoundaryDatabase = - { - FilePath = filePath, - CanUsePreprocessor = true, - UsePreprocessor = usePreprocessor, - PreprocessorDirectory = preprocessorDirectory - } - }); + FilePath = filePath, + CanUsePreprocessor = true, + UsePreprocessor = usePreprocessor, + PreprocessorDirectory = preprocessorDirectory + }; // Call - var properties = new HydraulicBoundaryDatabaseProperties(hydraulicBoundaryDatabaseContext); + var properties = new HydraulicBoundaryDatabaseProperties(hydraulicBoundaryDatabase); // Assert Assert.AreEqual(filePath, properties.FilePath); @@ -88,18 +83,15 @@ public void Constructor_CanUsePreprocessorTrue_PropertiesHaveExpectedAttributesValues(bool usePreprocessor) { // Setup - var context = new HydraulicBoundaryDatabaseContext(new AssessmentSection(AssessmentSectionComposition.Dike) + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { - HydraulicBoundaryDatabase = - { - CanUsePreprocessor = true, - UsePreprocessor = usePreprocessor, - PreprocessorDirectory = "Preprocessor" - } - }); + CanUsePreprocessor = true, + UsePreprocessor = usePreprocessor, + PreprocessorDirectory = "Preprocessor" + }; // Call - var properties = new HydraulicBoundaryDatabaseProperties(context); + var properties = new HydraulicBoundaryDatabaseProperties(hydraulicBoundaryDatabase); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -130,10 +122,10 @@ public void Constructor_CanUsePreprocessorFalse_PropertiesHaveExpectedAttributesValues() { // Setup - var context = new HydraulicBoundaryDatabaseContext(new AssessmentSection(AssessmentSectionComposition.Dike)); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); // Call - var properties = new HydraulicBoundaryDatabaseProperties(context); + var properties = new HydraulicBoundaryDatabaseProperties(hydraulicBoundaryDatabase); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -151,10 +143,10 @@ public void Constructor_HydraulicBoundaryDatabaseNotLinked_PropertiesHaveExpectedAttributesValues() { // Setup - var context = new HydraulicBoundaryDatabaseContext(new AssessmentSection(AssessmentSectionComposition.Dike)); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); // Call - var properties = new HydraulicBoundaryDatabaseProperties(context); + var properties = new HydraulicBoundaryDatabaseProperties(hydraulicBoundaryDatabase); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -179,25 +171,22 @@ mocks.ReplayAll(); - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { - HydraulicBoundaryDatabase = - { - CanUsePreprocessor = true, - UsePreprocessor = !usePreprocessor, - PreprocessorDirectory = "Preprocessor" - } + CanUsePreprocessor = true, + UsePreprocessor = !usePreprocessor, + PreprocessorDirectory = "Preprocessor" }; - var context = new HydraulicBoundaryDatabaseContext(assessmentSection); - var properties = new HydraulicBoundaryDatabaseProperties(context); - assessmentSection.Attach(observer); + var properties = new HydraulicBoundaryDatabaseProperties(hydraulicBoundaryDatabase); + hydraulicBoundaryDatabase.Attach(observer); + // Call properties.UsePreprocessor = usePreprocessor; // Assert - Assert.AreEqual(usePreprocessor, assessmentSection.HydraulicBoundaryDatabase.UsePreprocessor); + Assert.AreEqual(usePreprocessor, hydraulicBoundaryDatabase.UsePreprocessor); mocks.VerifyAll(); } @@ -206,23 +195,20 @@ { // Setup const string newPreprocessorDirectory = @"C:/path"; - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { - HydraulicBoundaryDatabase = - { - CanUsePreprocessor = true, - UsePreprocessor = true, - PreprocessorDirectory = "Preprocessor" - } + CanUsePreprocessor = true, + UsePreprocessor = true, + PreprocessorDirectory = "Preprocessor" }; - var context = new HydraulicBoundaryDatabaseContext(assessmentSection); - var properties = new HydraulicBoundaryDatabaseProperties(context); + var properties = new HydraulicBoundaryDatabaseProperties(hydraulicBoundaryDatabase); + // Call properties.PreprocessorDirectory = newPreprocessorDirectory; // Assert - Assert.AreEqual(newPreprocessorDirectory, assessmentSection.HydraulicBoundaryDatabase.PreprocessorDirectory); + Assert.AreEqual(newPreprocessorDirectory, hydraulicBoundaryDatabase.PreprocessorDirectory); } [Test] @@ -231,19 +217,17 @@ [Values(true, false)] bool usePreprocessor) { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); if (canUsePreprocessor) { - assessmentSection.HydraulicBoundaryDatabase.CanUsePreprocessor = true; - assessmentSection.HydraulicBoundaryDatabase.UsePreprocessor = usePreprocessor; - assessmentSection.HydraulicBoundaryDatabase.PreprocessorDirectory = "Preprocessor"; + hydraulicBoundaryDatabase.CanUsePreprocessor = true; + hydraulicBoundaryDatabase.UsePreprocessor = usePreprocessor; + hydraulicBoundaryDatabase.PreprocessorDirectory = "Preprocessor"; } - var context = new HydraulicBoundaryDatabaseContext(assessmentSection); - // Call - var properties = new HydraulicBoundaryDatabaseProperties(context); + var properties = new HydraulicBoundaryDatabaseProperties(hydraulicBoundaryDatabase); // Assert Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.FilePath))); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/HydraulicBoundaryDatabaseContextExportInfoTest.cs =================================================================== diff -u -r39e18750ccb61ad1f367279f9dac39a232d4f843 -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/HydraulicBoundaryDatabaseContextExportInfoTest.cs (.../HydraulicBoundaryDatabaseContextExportInfoTest.cs) (revision 39e18750ccb61ad1f367279f9dac39a232d4f843) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ExportInfos/HydraulicBoundaryDatabaseContextExportInfoTest.cs (.../HydraulicBoundaryDatabaseContextExportInfoTest.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -70,7 +70,7 @@ } } }; - var context = new HydraulicBoundaryDatabaseContext(assessmentSection); + var context = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, assessmentSection); const string filePath = "test"; using (var plugin = new RingtoetsPlugin()) @@ -106,7 +106,7 @@ { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - var context = new HydraulicBoundaryDatabaseContext(assessmentSection); + var context = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, assessmentSection); using (var plugin = new RingtoetsPlugin()) { @@ -131,7 +131,7 @@ FilePath = "databaseFile" } }; - var context = new HydraulicBoundaryDatabaseContext(assessmentSection); + var context = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, assessmentSection); using (var plugin = new RingtoetsPlugin()) { Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelLocationsContextPropertyInfoTest.cs =================================================================== diff -u -r75d12c89224759df39acf21f187f309a3e4ae274 -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelLocationsContextPropertyInfoTest.cs (.../DesignWaterLevelLocationsContextPropertyInfoTest.cs) (revision 75d12c89224759df39acf21f187f309a3e4ae274) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/DesignWaterLevelLocationsContextPropertyInfoTest.cs (.../DesignWaterLevelLocationsContextPropertyInfoTest.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -20,6 +20,7 @@ // All rights reserved. using System.Linq; +using Core.Common.Base; using Core.Common.Gui.Plugin; using Core.Common.Gui.PropertyBag; using NUnit.Framework; @@ -60,8 +61,10 @@ assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); mockRepository.ReplayAll(); - var context = new DesignWaterLevelLocationsContext(assessmentSection); + ObservableList locations = hydraulicBoundaryDatabase.Locations; + var context = new DesignWaterLevelLocationsContext(locations, assessmentSection); + using (var plugin = new RingtoetsPlugin()) { PropertyInfo info = GetInfo(plugin); @@ -71,7 +74,7 @@ // Assert Assert.IsInstanceOf(objectProperties); - Assert.AreSame(hydraulicBoundaryDatabase.Locations, objectProperties.Data); + Assert.AreSame(locations, objectProperties.Data); } mockRepository.VerifyAll(); } Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/HydraulicBoundaryDatabasePropertyInfoTest.cs =================================================================== diff -u -rf8c28b3b04cdabb62ea37772efcb1f4ebbbf2b9e -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/HydraulicBoundaryDatabasePropertyInfoTest.cs (.../HydraulicBoundaryDatabasePropertyInfoTest.cs) (revision f8c28b3b04cdabb62ea37772efcb1f4ebbbf2b9e) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/HydraulicBoundaryDatabasePropertyInfoTest.cs (.../HydraulicBoundaryDatabasePropertyInfoTest.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -61,14 +61,15 @@ public void CreateInstance_WithContext_ReturnHydraulicBoundaryDatabaseProperties() { // Setup - var context = new HydraulicBoundaryDatabaseContext(new AssessmentSection(AssessmentSectionComposition.Dike)); + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var context = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, assessmentSection); // Call IObjectProperties objectProperties = info.CreateInstance(context); // Assert Assert.IsInstanceOf(objectProperties); - Assert.AreSame(context, objectProperties.Data); + Assert.AreSame(context.WrappedData, objectProperties.Data); } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightLocationsContextPropertyInfoTest.cs =================================================================== diff -u -r75d12c89224759df39acf21f187f309a3e4ae274 -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightLocationsContextPropertyInfoTest.cs (.../WaveHeightLocationsContextPropertyInfoTest.cs) (revision 75d12c89224759df39acf21f187f309a3e4ae274) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/PropertyInfos/WaveHeightLocationsContextPropertyInfoTest.cs (.../WaveHeightLocationsContextPropertyInfoTest.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -60,7 +60,7 @@ assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); mockRepository.ReplayAll(); - var context = new WaveHeightLocationsContext(assessmentSection); + var context = new WaveHeightLocationsContext(hydraulicBoundaryDatabase.Locations, assessmentSection); using (var plugin = new RingtoetsPlugin()) { Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs =================================================================== diff -u -r1f0cd3fafaa7340a446612870810629587474302 -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision 1f0cd3fafaa7340a446612870810629587474302) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/AssessmentSectionTreeNodeInfoTest.cs (.../AssessmentSectionTreeNodeInfoTest.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -193,8 +193,8 @@ Assert.AreSame(assessmentSection, contributionContext.Parent); var context = (HydraulicBoundaryDatabaseContext) objects[3]; - Assert.AreSame(assessmentSection.HydraulicBoundaryDatabase, context.WrappedData.HydraulicBoundaryDatabase); - Assert.AreSame(assessmentSection, context.WrappedData); + Assert.AreSame(assessmentSection.HydraulicBoundaryDatabase, context.WrappedData); + Assert.AreSame(assessmentSection, context.AssessmentSection); var comment = (Comment) objects[4]; Assert.AreSame(assessmentSection.Comments, comment); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs =================================================================== diff -u -r39e18750ccb61ad1f367279f9dac39a232d4f843 -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs (.../DesignWaterLevelLocationsContextTreeNodeInfoTest.cs) (revision 39e18750ccb61ad1f367279f9dac39a232d4f843) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs (.../DesignWaterLevelLocationsContextTreeNodeInfoTest.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -25,6 +25,7 @@ using System.Linq; using System.Threading; using System.Windows.Forms; +using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.ContextMenu; @@ -136,7 +137,8 @@ menuBuilder.Expect(mb => mb.Build()).Return(null); } - var nodeData = new DesignWaterLevelLocationsContext(assessmentSection); + var nodeData = new DesignWaterLevelLocationsContext(new ObservableList(), + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -166,7 +168,8 @@ // Setup IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository); - var nodeData = new DesignWaterLevelLocationsContext(assessmentSection); + var nodeData = new DesignWaterLevelLocationsContext(new ObservableList(), + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -205,7 +208,8 @@ // Setup IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(null, mockRepository, "invalidFilePath"); - var nodeData = new DesignWaterLevelLocationsContext(assessmentSection); + var nodeData = new DesignWaterLevelLocationsContext(assessmentSection.HydraulicBoundaryDatabase.Locations, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -243,13 +247,16 @@ { // Setup var assessmentSection = mockRepository.Stub(); - assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { FilePath = Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "HydraulicBoundaryDatabaseImporter"), "complete.sqlite") - }); + }; - var nodeData = new DesignWaterLevelLocationsContext(assessmentSection); + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + var nodeData = new DesignWaterLevelLocationsContext(hydraulicBoundaryDatabase.Locations, + assessmentSection); + using (var treeViewControl = new TreeViewControl()) { var gui = mockRepository.Stub(); @@ -298,7 +305,8 @@ } }; - var context = new DesignWaterLevelLocationsContext(assessmentSection); + var context = new DesignWaterLevelLocationsContext(assessmentSection.HydraulicBoundaryDatabase.Locations, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -365,7 +373,8 @@ } }; - var context = new DesignWaterLevelLocationsContext(assessmentSection); + var context = new DesignWaterLevelLocationsContext(assessmentSection.HydraulicBoundaryDatabase.Locations, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -431,7 +440,8 @@ } }; - var context = new DesignWaterLevelLocationsContext(assessmentSection); + var context = new DesignWaterLevelLocationsContext(assessmentSection.HydraulicBoundaryDatabase.Locations, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -494,7 +504,8 @@ } }; - var context = new DesignWaterLevelLocationsContext(assessmentSection); + var context = new DesignWaterLevelLocationsContext(assessmentSection.HydraulicBoundaryDatabase.Locations, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs =================================================================== diff -u -r19e9491faa97f74a8e2a0533fbbaf34074549419 -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs (.../HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs) (revision 19e9491faa97f74a8e2a0533fbbaf34074549419) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs (.../HydraulicBoundaryDatabaseContextTreeNodeInfoTest.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -96,7 +96,8 @@ const string name = "Hydraulische randvoorwaarden"; var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - var context = new HydraulicBoundaryDatabaseContext(assessmentSection); + var context = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, + assessmentSection); using (var plugin = new RingtoetsPlugin()) { @@ -131,7 +132,8 @@ { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - var nodeData = new HydraulicBoundaryDatabaseContext(assessmentSection); + var nodeData = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, + assessmentSection); var menuBuilder = mocks.StrictMock(); using (mocks.Ordered()) @@ -173,7 +175,8 @@ { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection); + var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, + assessmentSection); using (var plugin = new RingtoetsPlugin()) { @@ -198,7 +201,8 @@ FilePath = "databaseFile" } }; - var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection); + var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, + assessmentSection); using (var plugin = new RingtoetsPlugin()) { @@ -217,7 +221,8 @@ { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection); + var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, + assessmentSection); using (var plugin = new RingtoetsPlugin()) { @@ -242,7 +247,8 @@ FilePath = "databaseFile" } }; - var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection); + var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, + assessmentSection); using (var plugin = new RingtoetsPlugin()) { @@ -254,10 +260,10 @@ // Assert Assert.AreEqual(2, objects.Length); var designWaterLevelLocationsContext = (DesignWaterLevelLocationsContext) objects[0]; - Assert.AreSame(assessmentSection, designWaterLevelLocationsContext.WrappedData); + Assert.AreSame(assessmentSection.HydraulicBoundaryDatabase.Locations, designWaterLevelLocationsContext.WrappedData); var waveHeightLocationsContext = (WaveHeightLocationsContext) objects[1]; - Assert.AreSame(assessmentSection, waveHeightLocationsContext.WrappedData); + Assert.AreSame(assessmentSection.HydraulicBoundaryDatabase.Locations, waveHeightLocationsContext.WrappedData); } } @@ -278,7 +284,8 @@ string testFile = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection); + var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, + assessmentSection); using (var treeViewControl = new TreeViewControl()) using (var plugin = new RingtoetsPlugin()) @@ -342,7 +349,8 @@ string testFile = Path.Combine(testDataPath, "empty.sqlite"); var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection); + var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, + assessmentSection); using (var treeViewControl = new TreeViewControl()) using (var plugin = new RingtoetsPlugin()) @@ -394,7 +402,8 @@ string testFile = Path.Combine(testDataPathNoHlcd, "HRD dutch coast south.sqlite"); var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection); + var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, + assessmentSection); using (var treeViewControl = new TreeViewControl()) using (var plugin = new RingtoetsPlugin()) @@ -453,7 +462,8 @@ assessmentSection.Attach(assessmentObserver); - var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection); + var hydraulicBoundaryDatabaseContext = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, + assessmentSection); var pipingOutput = new TestPipingOutput(); var pipingSemiProbabilisticOutput = new TestPipingSemiProbabilisticOutput(); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsContextTreeNodeInfoTest.cs =================================================================== diff -u -r39e18750ccb61ad1f367279f9dac39a232d4f843 -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsContextTreeNodeInfoTest.cs (.../WaveHeightLocationsContextTreeNodeInfoTest.cs) (revision 39e18750ccb61ad1f367279f9dac39a232d4f843) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/TreeNodeInfos/WaveHeightLocationsContextTreeNodeInfoTest.cs (.../WaveHeightLocationsContextTreeNodeInfoTest.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -25,6 +25,7 @@ using System.Linq; using System.Threading; using System.Windows.Forms; +using Core.Common.Base; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.ContextMenu; @@ -57,11 +58,6 @@ private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); - public override void Setup() - { - mockRepository = new MockRepository(); - } - [Test] public void Initialized_Always_ExpectedPropertiesSet() { @@ -142,7 +138,8 @@ menuBuilder.Expect(mb => mb.Build()).Return(null); } - var nodeData = new WaveHeightLocationsContext(assessmentSection); + var nodeData = new WaveHeightLocationsContext(new ObservableList(), + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -172,7 +169,8 @@ // Setup IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(mockRepository); - var nodeData = new WaveHeightLocationsContext(assessmentSection); + var nodeData = new WaveHeightLocationsContext(new ObservableList(), + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -211,7 +209,8 @@ // Setup IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(null, mockRepository, "invalidFilePath"); - var nodeData = new WaveHeightLocationsContext(assessmentSection); + var nodeData = new WaveHeightLocationsContext(assessmentSection.HydraulicBoundaryDatabase.Locations, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -248,14 +247,17 @@ public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemCalculateAllEnabled() { // Setup - var assessmentSection = mockRepository.Stub(); - assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { FilePath = Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "HydraulicBoundaryDatabaseImporter"), "complete.sqlite") - }); + }; - var nodeData = new WaveHeightLocationsContext(assessmentSection); + var assessmentSection = mockRepository.Stub(); + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + var nodeData = new WaveHeightLocationsContext(hydraulicBoundaryDatabase.Locations, + assessmentSection); + using (var treeViewControl = new TreeViewControl()) { var gui = mockRepository.Stub(); @@ -304,7 +306,8 @@ } }; - var context = new WaveHeightLocationsContext(assessmentSection); + var context = new WaveHeightLocationsContext(assessmentSection.HydraulicBoundaryDatabase.Locations, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -371,7 +374,8 @@ } }; - var context = new WaveHeightLocationsContext(assessmentSection); + var context = new WaveHeightLocationsContext(assessmentSection.HydraulicBoundaryDatabase.Locations, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -437,7 +441,8 @@ } }; - var context = new WaveHeightLocationsContext(assessmentSection); + var context = new WaveHeightLocationsContext(assessmentSection.HydraulicBoundaryDatabase.Locations, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -502,7 +507,8 @@ Id = string.Empty }; - var context = new WaveHeightLocationsContext(assessmentSection); + var context = new WaveHeightLocationsContext(assessmentSection.HydraulicBoundaryDatabase.Locations, + assessmentSection); using (var treeViewControl = new TreeViewControl()) { @@ -559,6 +565,11 @@ mockRepository.VerifyAll(); } + public override void Setup() + { + mockRepository = new MockRepository(); + } + private static TreeNodeInfo GetInfo(RingtoetsPlugin plugin) { return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(WaveHeightLocationsContext)); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs =================================================================== diff -u -rabc8aa5b19cab669083aeb2f4d1de51d687644b7 -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (.../DesignWaterLevelLocationsViewInfoTest.cs) (revision abc8aa5b19cab669083aeb2f4d1de51d687644b7) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (.../DesignWaterLevelLocationsViewInfoTest.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -110,21 +110,23 @@ { // Setup var assessmentSection = new ObservableTestAssessmentSectionStub(); - var context = new DesignWaterLevelLocationsContext(assessmentSection); + ObservableList locations = assessmentSection.HydraulicBoundaryDatabase.Locations; + var context = new DesignWaterLevelLocationsContext(locations, assessmentSection); // Call object viewData = info.GetViewData(context); // Assert - Assert.AreSame(assessmentSection.HydraulicBoundaryDatabase.Locations, viewData); + Assert.AreSame(locations, viewData); } [Test] public void CreateInstance_Always_SetExpectedProperties() { // Setup var assessmentSection = new ObservableTestAssessmentSectionStub(); - var context = new DesignWaterLevelLocationsContext(assessmentSection); + var context = new DesignWaterLevelLocationsContext(new ObservableList(), + assessmentSection); using (var ringtoetsPlugin = new RingtoetsPlugin()) { @@ -153,7 +155,8 @@ mocks.ReplayAll(); var assessmentSection = new ObservableTestAssessmentSectionStub(); - var context = new DesignWaterLevelLocationsContext(assessmentSection); + var context = new DesignWaterLevelLocationsContext(new ObservableList(), + assessmentSection); using (var view = new DesignWaterLevelLocationsView(new ObservableList(), new ObservableTestAssessmentSectionStub())) using (var ringtoetsPlugin = new RingtoetsPlugin()) Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs =================================================================== diff -u -rabc8aa5b19cab669083aeb2f4d1de51d687644b7 -rc114776ae9eae9848dd5841211bbe2105ae57dc7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.cs) (revision abc8aa5b19cab669083aeb2f4d1de51d687644b7) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.cs) (revision c114776ae9eae9848dd5841211bbe2105ae57dc7) @@ -110,21 +110,23 @@ { // Setup var assessmentSection = new ObservableTestAssessmentSectionStub(); - var context = new WaveHeightLocationsContext(assessmentSection); + ObservableList locations = assessmentSection.HydraulicBoundaryDatabase.Locations; + var context = new WaveHeightLocationsContext(locations, assessmentSection); + // Call object viewData = info.GetViewData(context); // Assert - Assert.AreSame(assessmentSection.HydraulicBoundaryDatabase.Locations, viewData); + Assert.AreSame(locations, viewData); } [Test] public void CreateInstance_Always_SetExpectedProperties() { // Setup var assessmentSection = new ObservableTestAssessmentSectionStub(); - var context = new WaveHeightLocationsContext(assessmentSection); + var context = new WaveHeightLocationsContext(new ObservableList(), assessmentSection); using (var ringtoetsPlugin = new RingtoetsPlugin()) { @@ -154,9 +156,10 @@ mocks.ReplayAll(); var assessmentSection = new ObservableTestAssessmentSectionStub(); - var context = new WaveHeightLocationsContext(assessmentSection); + var locations = new ObservableList(); + var context = new WaveHeightLocationsContext(locations, assessmentSection); - using (var view = new WaveHeightLocationsView(new ObservableList(), assessmentSection)) + using (var view = new WaveHeightLocationsView(locations, assessmentSection)) using (var ringtoetsPlugin = new RingtoetsPlugin()) { info = ringtoetsPlugin.GetViewInfos().First(tni => tni.ViewType == typeof(WaveHeightLocationsView));