Index: Riskeer/Storage/src/Riskeer.Storage.Core/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationScenarioCreateExtensions.cs
===================================================================
diff -u -r48f21c3256c73e5c4cbfed18a190b45223a1567d -r9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff
--- Riskeer/Storage/src/Riskeer.Storage.Core/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationScenarioCreateExtensions.cs (.../GrassCoverErosionInwardsCalculationScenarioCreateExtensions.cs) (revision 48f21c3256c73e5c4cbfed18a190b45223a1567d)
+++ Riskeer/Storage/src/Riskeer.Storage.Core/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationScenarioCreateExtensions.cs (.../GrassCoverErosionInwardsCalculationScenarioCreateExtensions.cs) (revision 9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff)
@@ -53,13 +53,13 @@
{
Name = calculation.Name.DeepClone(),
Comments = calculation.Comments.Body.DeepClone(),
+ RelevantForScenario = Convert.ToByte(calculation.IsRelevant),
+ ScenarioContribution = calculation.Contribution.ToNaNAsNull(),
Order = order
};
SetInputValues(entity, calculation.InputParameters, registry);
SetOutputEntity(entity, calculation);
- registry.Register(entity, calculation);
-
return entity;
}
Index: Riskeer/Storage/src/Riskeer.Storage.Core/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismCreateExtensions.cs
===================================================================
diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -r9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff
--- Riskeer/Storage/src/Riskeer.Storage.Core/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismCreateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismCreateExtensions.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea)
+++ Riskeer/Storage/src/Riskeer.Storage.Core/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismCreateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismCreateExtensions.cs) (revision 9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff)
@@ -76,7 +76,7 @@
{
foreach (GrassCoverErosionInwardsFailureMechanismSectionResult failureMechanismSectionResult in sectionResults)
{
- GrassCoverErosionInwardsSectionResultEntity sectionResultEntity = failureMechanismSectionResult.Create(registry);
+ GrassCoverErosionInwardsSectionResultEntity sectionResultEntity = failureMechanismSectionResult.Create();
FailureMechanismSectionEntity section = registry.Get(failureMechanismSectionResult.Section);
section.GrassCoverErosionInwardsSectionResultEntities.Add(sectionResultEntity);
}
Index: Riskeer/Storage/src/Riskeer.Storage.Core/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensions.cs
===================================================================
diff -u -r158e88a0d01e162f96688976523e0e503994e9cc -r9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff
--- Riskeer/Storage/src/Riskeer.Storage.Core/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensions.cs) (revision 158e88a0d01e162f96688976523e0e503994e9cc)
+++ Riskeer/Storage/src/Riskeer.Storage.Core/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensions.cs) (revision 9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff)
@@ -36,22 +36,15 @@
/// based on the information of the .
///
/// The result to create a database entity for.
- /// The object keeping track of create operations.
/// A new .
/// Thrown when any parameter is null.
- internal static GrassCoverErosionInwardsSectionResultEntity Create(this GrassCoverErosionInwardsFailureMechanismSectionResult result,
- PersistenceRegistry registry)
+ internal static GrassCoverErosionInwardsSectionResultEntity Create(this GrassCoverErosionInwardsFailureMechanismSectionResult result)
{
if (result == null)
{
throw new ArgumentNullException(nameof(result));
}
- if (registry == null)
- {
- throw new ArgumentNullException(nameof(registry));
- }
-
var sectionResultEntity = new GrassCoverErosionInwardsSectionResultEntity
{
SimpleAssessmentResult = Convert.ToByte(result.SimpleAssessmentResult),
Index: Riskeer/Storage/src/Riskeer.Storage.Core/Create/PersistenceRegistry.cs
===================================================================
diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -r9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff
--- Riskeer/Storage/src/Riskeer.Storage.Core/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea)
+++ Riskeer/Storage/src/Riskeer.Storage.Core/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff)
@@ -29,7 +29,6 @@
using Riskeer.Common.Data.Hydraulics;
using Riskeer.Common.Data.Structures;
using Riskeer.DuneErosion.Data;
-using Riskeer.GrassCoverErosionInwards.Data;
using Riskeer.HeightStructures.Data;
using Riskeer.MacroStabilityInwards.Data.SoilProfile;
using Riskeer.MacroStabilityInwards.Primitives;
@@ -57,9 +56,6 @@
private readonly Dictionary foreshoreProfiles =
CreateDictionary();
- private readonly Dictionary grassCoverErosionInwardsCalculations =
- CreateDictionary();
-
private readonly Dictionary pipingStochasticSoilModels =
CreateDictionary();
@@ -157,20 +153,6 @@
/// Registers a create operation for and the
/// that was constructed with the information.
///
- /// The
- /// to be registered.
- /// The to
- /// be registered.
- /// Thrown when any of the input parameters is null.
- internal void Register(GrassCoverErosionInwardsCalculationEntity entity, GrassCoverErosionInwardsCalculation model)
- {
- Register(grassCoverErosionInwardsCalculations, entity, model);
- }
-
- ///
- /// Registers a create operation for and the
- /// that was constructed with the information.
- ///
/// The to be registered.
/// The to be registered.
/// Thrown when any of the input parameters is null.
@@ -585,17 +567,6 @@
///
/// Checks whether a create operations has been registered for the given .
///
- /// The to check for.
- /// true if the was registered before, false otherwise.
- /// Thrown when is null.
- internal bool Contains(GrassCoverErosionInwardsCalculation model)
- {
- return ContainsValue(grassCoverErosionInwardsCalculations, model);
- }
-
- ///
- /// Checks whether a create operations has been registered for the given .
- ///
/// The to check for.
/// true if the was registered before, false otherwise.
/// Thrown when is null.
@@ -891,23 +862,6 @@
}
///
- /// Obtains the which was
- /// registered for the given .
- ///
- /// The for
- /// which a read operation has been registered.
- /// The constructed .
- /// Thrown when is null.
- /// Thrown when no create operation
- /// has been registered for .
- /// Use to find out
- /// whether a create operation has been registered for .
- internal GrassCoverErosionInwardsCalculationEntity Get(GrassCoverErosionInwardsCalculation model)
- {
- return Get(grassCoverErosionInwardsCalculations, model);
- }
-
- ///
/// Obtains the which was registered for the
/// given .
///
Index: Riskeer/Storage/src/Riskeer.Storage.Core/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensions.cs
===================================================================
diff -u -r48f21c3256c73e5c4cbfed18a190b45223a1567d -r9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff
--- Riskeer/Storage/src/Riskeer.Storage.Core/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensions.cs (.../GrassCoverErosionInwardsCalculationEntityReadExtensions.cs) (revision 48f21c3256c73e5c4cbfed18a190b45223a1567d)
+++ Riskeer/Storage/src/Riskeer.Storage.Core/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensions.cs (.../GrassCoverErosionInwardsCalculationEntityReadExtensions.cs) (revision 9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff)
@@ -62,7 +62,9 @@
Comments =
{
Body = entity.Comments
- }
+ },
+ IsRelevant = Convert.ToBoolean(entity.RelevantForScenario),
+ Contribution = (RoundedDouble) entity.ScenarioContribution.ToNullAsNaN(),
};
ReadInput(calculation.InputParameters, entity, collector);
ReadOutput(calculation, entity);
Fisheye: Tag 9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff refers to a dead (removed) revision in file `Riskeer/Storage/test/Riskeer.Storage.Core.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationCreateExtensionsTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/Storage/test/Riskeer.Storage.Core.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationScenarioCreateExtensionsTest.cs
===================================================================
diff -u
--- Riskeer/Storage/test/Riskeer.Storage.Core.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationScenarioCreateExtensionsTest.cs (revision 0)
+++ Riskeer/Storage/test/Riskeer.Storage.Core.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationScenarioCreateExtensionsTest.cs (revision 9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff)
@@ -0,0 +1,274 @@
+// Copyright (C) Stichting Deltares 2019. 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 Core.Common.Base.Data;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Riskeer.Common.Data.DikeProfiles;
+using Riskeer.Common.Data.Hydraulics;
+using Riskeer.Common.Data.TestUtil;
+using Riskeer.GrassCoverErosionInwards.Data;
+using Riskeer.Storage.Core.Create;
+using Riskeer.Storage.Core.Create.GrassCoverErosionInwards;
+using Riskeer.Storage.Core.DbContext;
+
+namespace Riskeer.Storage.Core.Test.Create.GrassCoverErosionInwards
+{
+ [TestFixture]
+ public class GrassCoverErosionInwardsCalculationScenarioCreateExtensionsTest
+ {
+ [Test]
+ public void Create_PersistenceRegistryNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var calculation = new GrassCoverErosionInwardsCalculationScenario();
+
+ // Call
+ void Call() => calculation.Create(null, 0);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("registry", exception.ParamName);
+ }
+
+ [Test]
+ [TestCase("I am comment")]
+ [TestCase(null)]
+ public void Create_ValidCalculation_ReturnEntity(string comment)
+ {
+ // Setup
+ var random = new Random(12);
+ int order = random.Next();
+ const string name = "GrassCoverErosionInwardsCalculation Name";
+ var calculation = new GrassCoverErosionInwardsCalculationScenario
+ {
+ Name = name,
+ Comments =
+ {
+ Body = comment
+ },
+ IsRelevant = random.NextBoolean(),
+ Contribution = random.NextRoundedDouble(),
+ InputParameters =
+ {
+ DikeProfile = null,
+ HydraulicBoundaryLocation = null,
+ DikeHeight = (RoundedDouble) 1.1,
+ Orientation = (RoundedDouble) 2.2,
+ BreakWater =
+ {
+ Height = (RoundedDouble) 3.3,
+ Type = BreakWaterType.Dam
+ },
+ DikeHeightCalculationType = random.NextEnumValue(),
+ OvertoppingRateCalculationType = random.NextEnumValue(),
+ CriticalFlowRate =
+ {
+ Mean = (RoundedDouble) 4.4,
+ StandardDeviation = (RoundedDouble) 5.5
+ },
+ UseBreakWater = true,
+ UseForeshore = false,
+ ShouldDikeHeightIllustrationPointsBeCalculated = random.NextBoolean(),
+ ShouldOvertoppingOutputIllustrationPointsBeCalculated = random.NextBoolean(),
+ ShouldOvertoppingRateIllustrationPointsBeCalculated = random.NextBoolean()
+ },
+ Output = null
+ };
+
+ var registry = new PersistenceRegistry();
+
+ // Call
+ GrassCoverErosionInwardsCalculationEntity entity = calculation.Create(registry, order);
+
+ // Assert
+ Assert.AreEqual(name, entity.Name);
+ Assert.AreEqual(comment, entity.Comments);
+ Assert.AreEqual(Convert.ToByte(calculation.IsRelevant), entity.RelevantForScenario);
+ Assert.AreEqual(calculation.Contribution, entity.ScenarioContribution);
+
+ Assert.AreEqual(order, entity.Order);
+
+ Assert.IsNull(entity.DikeProfileEntity);
+ Assert.IsNull(entity.HydraulicLocationEntity);
+
+ GrassCoverErosionInwardsInput input = calculation.InputParameters;
+ Assert.AreEqual(input.BreakWater.Height.Value, entity.BreakWaterHeight);
+ Assert.AreEqual((short) input.BreakWater.Type, entity.BreakWaterType);
+ Assert.AreEqual(Convert.ToByte(input.UseBreakWater), entity.UseBreakWater);
+ Assert.AreEqual(input.CriticalFlowRate.Mean.Value, entity.CriticalFlowRateMean);
+ Assert.AreEqual(input.CriticalFlowRate.StandardDeviation.Value, entity.CriticalFlowRateStandardDeviation);
+ Assert.AreEqual(input.Orientation.Value, entity.Orientation);
+ Assert.AreEqual(Convert.ToByte(input.DikeHeightCalculationType), entity.DikeHeightCalculationType);
+ Assert.AreEqual(Convert.ToByte(input.OvertoppingRateCalculationType), entity.OvertoppingRateCalculationType);
+ Assert.AreEqual(input.DikeHeight.Value, entity.DikeHeight);
+ Assert.AreEqual(Convert.ToByte(input.UseForeshore), entity.UseForeshore);
+
+ Assert.AreEqual(Convert.ToByte(input.ShouldDikeHeightIllustrationPointsBeCalculated),
+ entity.ShouldDikeHeightIllustrationPointsBeCalculated);
+ Assert.AreEqual(Convert.ToByte(input.ShouldOvertoppingOutputIllustrationPointsBeCalculated),
+ entity.ShouldOvertoppingOutputIllustrationPointsBeCalculated);
+ Assert.AreEqual(Convert.ToByte(input.ShouldOvertoppingRateIllustrationPointsBeCalculated),
+ entity.ShouldOvertoppingRateIllustrationPointsBeCalculated);
+
+ Assert.IsFalse(entity.GrassCoverErosionInwardsOutputEntities.Any());
+ }
+
+ [Test]
+ public void Create_StringPropertiesDoNotShareReference()
+ {
+ // Setup
+ const string name = "A";
+ const string comment = "B";
+ var calculation = new GrassCoverErosionInwardsCalculationScenario
+ {
+ Name = name,
+ Comments =
+ {
+ Body = comment
+ }
+ };
+
+ var registry = new PersistenceRegistry();
+
+ // Call
+ GrassCoverErosionInwardsCalculationEntity entity = calculation.Create(registry, 0);
+
+ // Assert
+ Assert.AreNotSame(name, entity.Name,
+ "To create stable binary representations/fingerprints, it's really important that strings are not shared.");
+ Assert.AreEqual(name, entity.Name);
+
+ Assert.AreNotSame(comment, entity.Comments,
+ "To create stable binary representations/fingerprints, it's really important that strings are not shared.");
+ Assert.AreEqual(comment, entity.Comments);
+ }
+
+ [Test]
+ public void Create_NaNParameters_EntityWithNullFields()
+ {
+ // Setup
+ var calculation = new GrassCoverErosionInwardsCalculationScenario
+ {
+ InputParameters =
+ {
+ Orientation = RoundedDouble.NaN,
+ CriticalFlowRate =
+ {
+ Mean = RoundedDouble.NaN,
+ StandardDeviation = RoundedDouble.NaN
+ },
+ DikeHeight = RoundedDouble.NaN,
+ BreakWater =
+ {
+ Height = RoundedDouble.NaN
+ }
+ }
+ };
+ var registry = new PersistenceRegistry();
+
+ // Call
+ GrassCoverErosionInwardsCalculationEntity entity = calculation.Create(registry, 0);
+
+ // Assert
+ Assert.IsNull(entity.Orientation);
+ Assert.IsNull(entity.CriticalFlowRateMean);
+ Assert.IsNull(entity.CriticalFlowRateStandardDeviation);
+ Assert.IsNull(entity.DikeHeight);
+ Assert.IsNull(entity.BreakWaterHeight);
+ }
+
+ [Test]
+ public void Create_CalculationWithAlreadySavedDikeProfile_ReturnEntityWithDikeProfileEntity()
+ {
+ // Setup
+ DikeProfile dikeProfile = DikeProfileTestFactory.CreateDikeProfile();
+ var calculation = new GrassCoverErosionInwardsCalculationScenario
+ {
+ InputParameters =
+ {
+ DikeProfile = dikeProfile
+ }
+ };
+
+ var dikeProfileEntity = new DikeProfileEntity();
+ var registry = new PersistenceRegistry();
+ registry.Register(dikeProfileEntity, dikeProfile);
+
+ // Call
+ GrassCoverErosionInwardsCalculationEntity entity = calculation.Create(registry, 0);
+
+ // Assert
+ Assert.AreSame(dikeProfileEntity, entity.DikeProfileEntity);
+ }
+
+ [Test]
+ public void Create_CalculationWithAlreadySavedHydraulicBoundaryLocation_ReturnEntityWithHydraulicLocationEntity()
+ {
+ // Setup
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "A", 1, 1);
+ var calculation = new GrassCoverErosionInwardsCalculationScenario
+ {
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = hydraulicBoundaryLocation
+ }
+ };
+
+ var hydraulicLocationEntity = new HydraulicLocationEntity();
+ var registry = new PersistenceRegistry();
+ registry.Register(hydraulicLocationEntity, hydraulicBoundaryLocation);
+
+ // Call
+ GrassCoverErosionInwardsCalculationEntity entity = calculation.Create(registry, 0);
+
+ // Assert
+ Assert.AreSame(hydraulicLocationEntity, entity.HydraulicLocationEntity);
+ }
+
+ [Test]
+ public void Create_CalculationWithOutput_ReturnEntity()
+ {
+ // Setup
+ var random = new Random(456);
+ var overtoppingOutput = new OvertoppingOutput(random.NextDouble(), false, random.NextDouble(), null);
+ var output = new GrassCoverErosionInwardsOutput(overtoppingOutput, null, null);
+
+ var calculation = new GrassCoverErosionInwardsCalculationScenario
+ {
+ Output = output
+ };
+
+ var registry = new PersistenceRegistry();
+
+ // Call
+ GrassCoverErosionInwardsCalculationEntity entity = calculation.Create(registry, 0);
+
+ // Assert
+ GrassCoverErosionInwardsOutputEntity outputEntity = entity.GrassCoverErosionInwardsOutputEntities.Single();
+ Assert.AreEqual(overtoppingOutput.WaveHeight, outputEntity.WaveHeight);
+ Assert.AreEqual(overtoppingOutput.Reliability, outputEntity.Reliability);
+ Assert.IsNull(outputEntity.GeneralResultFaultTreeIllustrationPointEntity);
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Storage/test/Riskeer.Storage.Core.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensionsTest.cs
===================================================================
diff -u -r158e88a0d01e162f96688976523e0e503994e9cc -r9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff
--- Riskeer/Storage/test/Riskeer.Storage.Core.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensionsTest.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensionsTest.cs) (revision 158e88a0d01e162f96688976523e0e503994e9cc)
+++ Riskeer/Storage/test/Riskeer.Storage.Core.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensionsTest.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensionsTest.cs) (revision 9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff)
@@ -25,7 +25,6 @@
using Riskeer.Common.Data.TestUtil;
using Riskeer.Common.Primitives;
using Riskeer.GrassCoverErosionInwards.Data;
-using Riskeer.Storage.Core.Create;
using Riskeer.Storage.Core.Create.GrassCoverErosionInwards;
using Riskeer.Storage.Core.DbContext;
@@ -38,28 +37,14 @@
public void Create_FailureMechanismSectionResultNull_ThrowsArgumentNullException()
{
// Call
- TestDelegate call = () => ((GrassCoverErosionInwardsFailureMechanismSectionResult) null).Create(new PersistenceRegistry());
+ void Call() => ((GrassCoverErosionInwardsFailureMechanismSectionResult) null).Create();
// Assert
- var exception = Assert.Throws(call);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("result", exception.ParamName);
}
[Test]
- public void Create_PersistencyRegistryNull_ThrowsArgumentNullException()
- {
- // Setup
- var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
-
- // Call
- TestDelegate test = () => sectionResult.Create(null);
-
- // Assert
- var exception = Assert.Throws(test);
- Assert.AreEqual("registry", exception.ParamName);
- }
-
- [Test]
public void Create_WithDifferentResults_ReturnsEntityWithExpectedResults()
{
// Setup
@@ -82,7 +67,7 @@
};
// Call
- GrassCoverErosionInwardsSectionResultEntity entity = sectionResult.Create(new PersistenceRegistry());
+ GrassCoverErosionInwardsSectionResultEntity entity = sectionResult.Create();
// Assert
Assert.AreEqual(Convert.ToByte(simpleAssessmentResult), entity.SimpleAssessmentResult);
@@ -91,8 +76,6 @@
Assert.AreEqual(tailorMadeAssessmentProbability, entity.TailorMadeAssessmentProbability);
Assert.AreEqual(Convert.ToByte(useManualAssembly), entity.UseManualAssembly);
Assert.AreEqual(manualAssemblyProbability, entity.ManualAssemblyProbability);
-
- Assert.IsNull(entity.GrassCoverErosionInwardsCalculationEntity);
}
[Test]
@@ -106,7 +89,7 @@
};
// Call
- GrassCoverErosionInwardsSectionResultEntity entity = sectionResult.Create(new PersistenceRegistry());
+ GrassCoverErosionInwardsSectionResultEntity entity = sectionResult.Create();
// Assert
Assert.IsNull(entity.TailorMadeAssessmentProbability);
Index: Riskeer/Storage/test/Riskeer.Storage.Core.Test/Create/PersistenceRegistryTest.cs
===================================================================
diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -r9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff
--- Riskeer/Storage/test/Riskeer.Storage.Core.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea)
+++ Riskeer/Storage/test/Riskeer.Storage.Core.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff)
@@ -33,7 +33,6 @@
using Riskeer.Common.Data.TestUtil;
using Riskeer.DuneErosion.Data;
using Riskeer.DuneErosion.Data.TestUtil;
-using Riskeer.GrassCoverErosionInwards.Data;
using Riskeer.HeightStructures.Data;
using Riskeer.HeightStructures.Data.TestUtil;
using Riskeer.MacroStabilityInwards.Data.SoilProfile;
@@ -337,26 +336,7 @@
}
#endregion
-
- #region GrassCoverErosionInwards
-
- [TestFixture]
- private class GrassCoverErosionInwardsCalculationRegistryTest : RegistryTest<
- GrassCoverErosionInwardsCalculation, GrassCoverErosionInwardsCalculationEntity>
- {
- public GrassCoverErosionInwardsCalculationRegistryTest() : base(
- (r, e, m) => r.Register(e, m),
- (r, m) => r.Contains(m),
- (r, m) => r.Get(m)) {}
-
- protected override GrassCoverErosionInwardsCalculation CreateDataModel()
- {
- return new GrassCoverErosionInwardsCalculation();
- }
- }
-
- #endregion
-
+
#region Piping
[TestFixture]
Index: Riskeer/Storage/test/Riskeer.Storage.Core.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs
===================================================================
diff -u -r158e88a0d01e162f96688976523e0e503994e9cc -r9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff
--- Riskeer/Storage/test/Riskeer.Storage.Core.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 158e88a0d01e162f96688976523e0e503994e9cc)
+++ Riskeer/Storage/test/Riskeer.Storage.Core.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff)
@@ -217,15 +217,15 @@
using (var gui = new GuiCore(new MainWindow(), projectStore, projectMigrator, new RiskeerProjectFactory(), new GuiCoreSettings()))
{
// When
- Action action = () => gui.Run(projectFilePath);
+ void Action() => gui.Run(projectFilePath);
// Then
Tuple[] expectedMessages =
{
Tuple.Create("Openen van project is gestart.", LogLevelConstant.Info),
Tuple.Create("Openen van project is gelukt.", LogLevelConstant.Info)
};
- TestHelper.AssertLogMessagesWithLevelAreGenerated(action, expectedMessages, 3);
+ TestHelper.AssertLogMessagesWithLevelAreGenerated(Action, expectedMessages, 3);
Assert.AreEqual(projectFilePath, gui.ProjectFilePath);
Assert.NotNull(gui.Project);
Assert.AreEqual(expectedProjectName, gui.Project.Name);
@@ -510,62 +510,52 @@
Assert.AreEqual(expectedChild.GetType(), actualChild.GetType());
- var expectedChildGroup = expectedChild as CalculationGroup;
- if (expectedChildGroup != null)
+ if (expectedChild is CalculationGroup expectedChildGroup)
{
AssertCalculationGroup(expectedChildGroup, (CalculationGroup) actualChild);
}
- var expectedPipingCalculation = expectedChild as PipingCalculationScenario;
- if (expectedPipingCalculation != null)
+ if (expectedChild is PipingCalculationScenario expectedPipingCalculation)
{
AssertPipingCalculationScenario(expectedPipingCalculation, (PipingCalculationScenario) actualChild);
}
- var expectedMacroStabilityInwardsCalculation = expectedChild as MacroStabilityInwardsCalculationScenario;
- if (expectedMacroStabilityInwardsCalculation != null)
+ if (expectedChild is MacroStabilityInwardsCalculationScenario expectedMacroStabilityInwardsCalculation)
{
AssertMacroStabilityInwardsCalculationScenario(expectedMacroStabilityInwardsCalculation, (MacroStabilityInwardsCalculationScenario) actualChild);
}
- var expectedGrassCoverErosionInwardsCalculation = expectedChild as GrassCoverErosionInwardsCalculation;
- if (expectedGrassCoverErosionInwardsCalculation != null)
+ if (expectedChild is GrassCoverErosionInwardsCalculationScenario expectedGrassCoverErosionInwardsCalculation)
{
- AssertGrassCoverErosionInwardsCalculation(expectedGrassCoverErosionInwardsCalculation, (GrassCoverErosionInwardsCalculation) actualChild);
+ AssertGrassCoverErosionInwardsCalculationScenario(expectedGrassCoverErosionInwardsCalculation, (GrassCoverErosionInwardsCalculationScenario) actualChild);
}
- var expectedGrassCoverErosionOutwardsCalculation = expectedChild as GrassCoverErosionOutwardsWaveConditionsCalculation;
- if (expectedGrassCoverErosionOutwardsCalculation != null)
+ if (expectedChild is GrassCoverErosionOutwardsWaveConditionsCalculation expectedGrassCoverErosionOutwardsCalculation)
{
AssertGrassCoverErosionOutwardsWaveConditionsCalculation(expectedGrassCoverErosionOutwardsCalculation, (GrassCoverErosionOutwardsWaveConditionsCalculation) actualChild);
}
- var expectedHeightStructuresCalculation = expectedChild as StructuresCalculation;
- if (expectedHeightStructuresCalculation != null)
+ if (expectedChild is StructuresCalculation expectedHeightStructuresCalculation)
{
AssertStructuresCalculation(expectedHeightStructuresCalculation, (StructuresCalculation) actualChild);
}
- var expectedClosingStructuresCalculation = expectedChild as StructuresCalculation;
- if (expectedClosingStructuresCalculation != null)
+ if (expectedChild is StructuresCalculation expectedClosingStructuresCalculation)
{
AssertStructuresCalculation(expectedClosingStructuresCalculation, (StructuresCalculation) actualChild);
}
- var expectedStabilityPointStructuresCalculation = expectedChild as StructuresCalculation;
- if (expectedStabilityPointStructuresCalculation != null)
+ if (expectedChild is StructuresCalculation expectedStabilityPointStructuresCalculation)
{
AssertStructuresCalculation(expectedStabilityPointStructuresCalculation, (StructuresCalculation) actualChild);
}
- var expectedStabilityStoneCoverWaveConditionsCalculation = expectedChild as StabilityStoneCoverWaveConditionsCalculation;
- if (expectedStabilityStoneCoverWaveConditionsCalculation != null)
+ if (expectedChild is StabilityStoneCoverWaveConditionsCalculation expectedStabilityStoneCoverWaveConditionsCalculation)
{
AssertStabilityStoneCoverWaveConditionsCalculation(expectedStabilityStoneCoverWaveConditionsCalculation, (StabilityStoneCoverWaveConditionsCalculation) actualChild);
}
- var expectedWaveImpactAsphaltCoverWaveConditionsCalculation = expectedChild as WaveImpactAsphaltCoverWaveConditionsCalculation;
- if (expectedWaveImpactAsphaltCoverWaveConditionsCalculation != null)
+ if (expectedChild is WaveImpactAsphaltCoverWaveConditionsCalculation expectedWaveImpactAsphaltCoverWaveConditionsCalculation)
{
AssertWaveImpactAsphaltCoverWaveConditionsCalculation(expectedWaveImpactAsphaltCoverWaveConditionsCalculation, (WaveImpactAsphaltCoverWaveConditionsCalculation) actualChild);
}
@@ -1448,16 +1438,14 @@
{
Assert.AreEqual(expectedProfile.Probability, actualProfile.Probability);
- var expectedSoilProfile1D = expectedProfile.SoilProfile as MacroStabilityInwardsSoilProfile1D;
- if (expectedSoilProfile1D != null)
+ if (expectedProfile.SoilProfile is MacroStabilityInwardsSoilProfile1D expectedSoilProfile1D)
{
var actualSoilProfile1D = actualProfile.SoilProfile as MacroStabilityInwardsSoilProfile1D;
Assert.IsNotNull(actualSoilProfile1D);
AssertMacroStabilityInwardsSoilProfile(expectedSoilProfile1D, actualSoilProfile1D);
}
- var expectedSoilProfile2D = expectedProfile.SoilProfile as MacroStabilityInwardsSoilProfile2D;
- if (expectedSoilProfile2D != null)
+ if (expectedProfile.SoilProfile is MacroStabilityInwardsSoilProfile2D expectedSoilProfile2D)
{
var actualSoilProfile2D = actualProfile.SoilProfile as MacroStabilityInwardsSoilProfile2D;
Assert.IsNotNull(actualSoilProfile2D);
@@ -1584,7 +1572,7 @@
Assert.AreEqual(expectedInput.MinimumLevelPhreaticLineAtDikeTopRiver, actualInput.MinimumLevelPhreaticLineAtDikeTopRiver);
Assert.AreEqual(expectedInput.MinimumLevelPhreaticLineAtDikeTopPolder, actualInput.MinimumLevelPhreaticLineAtDikeTopPolder);
- AsssertMacroStabilityInwardsLocationInputBase(expectedInput.LocationInputDaily, actualInput.LocationInputDaily);
+ AssertMacroStabilityInwardsLocationInputBase(expectedInput.LocationInputDaily, actualInput.LocationInputDaily);
AssertMacroStabilityInwardsLocationInput(expectedInput.LocationInputExtreme, actualInput.LocationInputExtreme);
Assert.AreEqual(expectedInput.AdjustPhreaticLine3And4ForUplift, actualInput.AdjustPhreaticLine3And4ForUplift);
@@ -1619,21 +1607,21 @@
Assert.AreEqual(expectedGrid.NumberOfVerticalPoints, actualGrid.NumberOfVerticalPoints);
}
- private static void AsssertMacroStabilityInwardsLocationInputBase(IMacroStabilityInwardsLocationInput expectedLocationInput,
- IMacroStabilityInwardsLocationInput actuaLocationInput)
+ private static void AssertMacroStabilityInwardsLocationInputBase(IMacroStabilityInwardsLocationInput expectedLocationInput,
+ IMacroStabilityInwardsLocationInput actualLocationInput)
{
- Assert.AreEqual(expectedLocationInput.WaterLevelPolder, actuaLocationInput.WaterLevelPolder);
- Assert.AreEqual(expectedLocationInput.UseDefaultOffsets, actuaLocationInput.UseDefaultOffsets);
- Assert.AreEqual(expectedLocationInput.PhreaticLineOffsetBelowDikeTopAtRiver, actuaLocationInput.PhreaticLineOffsetBelowDikeTopAtRiver);
- Assert.AreEqual(expectedLocationInput.PhreaticLineOffsetBelowDikeTopAtPolder, actuaLocationInput.PhreaticLineOffsetBelowDikeTopAtPolder);
- Assert.AreEqual(expectedLocationInput.PhreaticLineOffsetBelowShoulderBaseInside, actuaLocationInput.PhreaticLineOffsetBelowShoulderBaseInside);
- Assert.AreEqual(expectedLocationInput.PhreaticLineOffsetBelowDikeToeAtPolder, actuaLocationInput.PhreaticLineOffsetBelowDikeToeAtPolder);
+ Assert.AreEqual(expectedLocationInput.WaterLevelPolder, actualLocationInput.WaterLevelPolder);
+ Assert.AreEqual(expectedLocationInput.UseDefaultOffsets, actualLocationInput.UseDefaultOffsets);
+ Assert.AreEqual(expectedLocationInput.PhreaticLineOffsetBelowDikeTopAtRiver, actualLocationInput.PhreaticLineOffsetBelowDikeTopAtRiver);
+ Assert.AreEqual(expectedLocationInput.PhreaticLineOffsetBelowDikeTopAtPolder, actualLocationInput.PhreaticLineOffsetBelowDikeTopAtPolder);
+ Assert.AreEqual(expectedLocationInput.PhreaticLineOffsetBelowShoulderBaseInside, actualLocationInput.PhreaticLineOffsetBelowShoulderBaseInside);
+ Assert.AreEqual(expectedLocationInput.PhreaticLineOffsetBelowDikeToeAtPolder, actualLocationInput.PhreaticLineOffsetBelowDikeToeAtPolder);
}
private static void AssertMacroStabilityInwardsLocationInput(IMacroStabilityInwardsLocationInputExtreme expectedLocationInput,
IMacroStabilityInwardsLocationInputExtreme actualLocationInput)
{
- AsssertMacroStabilityInwardsLocationInputBase(expectedLocationInput, actualLocationInput);
+ AssertMacroStabilityInwardsLocationInputBase(expectedLocationInput, actualLocationInput);
Assert.AreEqual(expectedLocationInput.PenetrationLength, actualLocationInput.PenetrationLength);
}
@@ -1757,9 +1745,11 @@
});
}
- private static void AssertGrassCoverErosionInwardsCalculation(GrassCoverErosionInwardsCalculation expectedCalculation,
- GrassCoverErosionInwardsCalculation actualCalculation)
+ private static void AssertGrassCoverErosionInwardsCalculationScenario(GrassCoverErosionInwardsCalculationScenario expectedCalculation,
+ GrassCoverErosionInwardsCalculationScenario actualCalculation)
{
+ Assert.AreEqual(expectedCalculation.IsRelevant, actualCalculation.IsRelevant);
+ Assert.AreEqual(expectedCalculation.Contribution, actualCalculation.Contribution);
Assert.AreEqual(expectedCalculation.Name, actualCalculation.Name);
AssertComments(expectedCalculation.Comments, actualCalculation.Comments);
@@ -2232,8 +2222,7 @@
private static void AssertIllustrationPointNode(IllustrationPointNode expected,
IllustrationPointNode actual)
{
- var expectedFaultTreeIllustrationPoint = expected.Data as FaultTreeIllustrationPoint;
- if (expectedFaultTreeIllustrationPoint != null)
+ if (expected.Data is FaultTreeIllustrationPoint expectedFaultTreeIllustrationPoint)
{
var actualFaultTreeIllustrationPoint = actual.Data as FaultTreeIllustrationPoint;
Assert.IsNotNull(actualFaultTreeIllustrationPoint);
@@ -2247,8 +2236,7 @@
return;
}
- var expectedSubMechanismIllustrationPoint = expected.Data as SubMechanismIllustrationPoint;
- if (expectedSubMechanismIllustrationPoint != null)
+ if (expected.Data is SubMechanismIllustrationPoint expectedSubMechanismIllustrationPoint)
{
var actualSubMechanismIllustrationPoint = actual.Data as SubMechanismIllustrationPoint;
Assert.IsNotNull(actualSubMechanismIllustrationPoint);
Index: Riskeer/Storage/test/Riskeer.Storage.Core.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs
===================================================================
diff -u -r48f21c3256c73e5c4cbfed18a190b45223a1567d -r9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff
--- Riskeer/Storage/test/Riskeer.Storage.Core.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs (.../GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs) (revision 48f21c3256c73e5c4cbfed18a190b45223a1567d)
+++ Riskeer/Storage/test/Riskeer.Storage.Core.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs (.../GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs) (revision 9793bc3048c48b4c25bcde1d0c07d6d02b53b2ff)
@@ -45,11 +45,11 @@
var entity = new GrassCoverErosionInwardsCalculationEntity();
// Call
- TestDelegate call = () => entity.Read(null);
+ void Call() => entity.Read(null);
// Assert
- string paramName = Assert.Throws(call).ParamName;
- Assert.AreEqual("collector", paramName);
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("collector", exception.ParamName);
}
[Test]
@@ -78,17 +78,21 @@
OvertoppingRateCalculationType = Convert.ToByte(overtoppingRateCalculationType),
ShouldOvertoppingOutputIllustrationPointsBeCalculated = Convert.ToByte(random.NextBoolean()),
ShouldDikeHeightIllustrationPointsBeCalculated = Convert.ToByte(random.NextBoolean()),
- ShouldOvertoppingRateIllustrationPointsBeCalculated = Convert.ToByte(random.NextBoolean())
+ ShouldOvertoppingRateIllustrationPointsBeCalculated = Convert.ToByte(random.NextBoolean()),
+ RelevantForScenario = Convert.ToByte(random.NextBoolean()),
+ ScenarioContribution = 4.5
};
var collector = new ReadConversionCollector();
// Call
- GrassCoverErosionInwardsCalculation calculation = entity.Read(collector);
+ GrassCoverErosionInwardsCalculationScenario calculation = entity.Read(collector);
// Assert
Assert.AreEqual(entity.Name, calculation.Name);
Assert.AreEqual(entity.Comments, calculation.Comments.Body);
+ AssertBoolean(entity.RelevantForScenario, calculation.IsRelevant);
+ Assert.AreEqual(entity.ScenarioContribution, calculation.Contribution);
GrassCoverErosionInwardsInput input = calculation.InputParameters;
Assert.AreEqual(entity.Orientation, input.Orientation.Value);