Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs =================================================================== diff -u -r944d2501b3f780d208e00015a1b850afad4c3aa8 -r11f0867b39150ae5fac83dc178a89fee46d27611 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 944d2501b3f780d208e00015a1b850afad4c3aa8) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 11f0867b39150ae5fac83dc178a89fee46d27611) @@ -20,31 +20,19 @@ // All rights reserved. using System; -using System.Linq; using Application.Ringtoets.Storage.Create; using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.TestUtil; using Core.Common.Base.Geometry; using NUnit.Framework; -using Rhino.Mocks; -using Ringtoets.Common.Data.AssessmentSection; -using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; -using Ringtoets.Common.Data.Probability; using Ringtoets.GrassCoverErosionInwards.Data; -using Ringtoets.GrassCoverErosionOutwards.Data; -using Ringtoets.HeightStructures.Data; using Ringtoets.HydraRing.Data; -using Ringtoets.Integration.Data; -using Ringtoets.Integration.Data.StandAlone; -using Ringtoets.Integration.Data.StandAlone.SectionResults; using Ringtoets.Piping.Data; using Ringtoets.Piping.Data.TestUtil; using Ringtoets.Piping.KernelWrapper.TestUtil; using Ringtoets.Piping.Primitives; -using Ringtoets.StabilityStoneCover.Data; -using Ringtoets.WaveImpactAsphaltCover.Data; namespace Application.Ringtoets.Storage.Test.Create { @@ -1022,92 +1010,6 @@ #region Register methods [Test] - public void Register_WithNullProjectEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new RingtoetsProject()); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullProject_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new ProjectEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullAssessmentSectionEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new AssessmentSection(AssessmentSectionComposition.Dike)); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullAssessmentSection_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new AssessmentSectionEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullFailureMechanismEntity_ThrowsArgumentNullException() - { - // Setup - var mocks = new MockRepository(); - var model = mocks.StrictMock(); - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, model); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullFailureMechanismBase_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new FailureMechanismEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] public void Register_WithNullFailureMechanismSection_ThrowsArgumentNullException() { // Setup @@ -1136,62 +1038,6 @@ } [Test] - public void Register_WithNullPipingFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new PipingSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullPipingSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new PipingFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullGeneralGrassCoverErosionInwardsInput_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new GrassCoverErosionInwardsFailureMechanismMetaEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullGrassCoverErosionInwardsFailureMechanismMetaEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new GeneralGrassCoverErosionInwardsInput()); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] public void Register_WithNullDikeProfile_ThrowsArgumentNullException() { // Setup @@ -1248,540 +1094,6 @@ } [Test] - public void Register_WithNullGrassCoverErosionInwardsOutput_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new GrassCoverErosionInwardsOutputEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullGrassCoverErosionInwardsOutputEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - var output = new GrassCoverErosionInwardsOutput(1, false, new ProbabilityAssessmentOutput(1, 1, 1, 1, 1), 1); - - // Call - TestDelegate test = () => registry.Register(null, output); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullProbabilityAssessmentOutput_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new ProbabilisticOutputEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullProbabilisticOutputEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - var output = new ProbabilityAssessmentOutput(1, 1, 1, 1, 1); - - // Call - TestDelegate test = () => registry.Register(null, output); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullGrassCoverErosionInwardsFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new GrassCoverErosionInwardsSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullGrassCoverErosionInwardsSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new GrassCoverErosionInwardsFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullHeightStructuresFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new HeightStructuresSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullHeightStructuresSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new HeightStructuresFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullStrengthStabilityLengthwiseConstructionFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new StrengthStabilityLengthwiseConstructionSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullStrengthStabilityLengthwiseConstructionSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullTechnicalInnovationFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new TechnicalInnovationSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullTechnicalInnovationSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new TechnicalInnovationFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullWaterPressureAsphaltCoverFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new WaterPressureAsphaltCoverSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullWaterPressureAsphaltCoverSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new WaterPressureAsphaltCoverFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullClosingStructureFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new ClosingStructureSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullClosingStructureSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new ClosingStructureFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullMacrostabilityInwardsFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new MacrostabilityInwardsSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullMacrostabilityInwardsSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new MacrostabilityInwardsFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullMacrostabilityOutwardsFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new MacrostabilityOutwardsSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullMacrostabilityOutwardsSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new MacrostabilityOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullWaveImpactAsphaltCoverFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new WaveImpactAsphaltCoverSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullWaveImpactAsphaltCoverSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new WaveImpactAsphaltCoverFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullGrassCoverErosionOutwardsFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new GrassCoverErosionOutwardsSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullGrassCoverErosionOutwardsSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new GrassCoverErosionOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullGrassCoverSlipOffInwardsFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new GrassCoverSlipOffInwardsSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullGrassCoverSlipOffInwardsSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullGrassCoverSlipOffOutwardsFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new GrassCoverSlipOffOutwardsSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullGrassCoverSlipOffOutwardsSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullMicrostabilityFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new MicrostabilitySectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullMicrostabilitySectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullPipingStructureFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new PipingStructureSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullPipingStructureSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullDuneErosionFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new DuneErosionSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullDuneErosionSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new DuneErosionFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullStabilityStoneCoverFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new StabilityStoneCoverSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullStabilityStoneCoverSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new StabilityStoneCoverFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullStrengthStabilityPointConstructionFailureMechanismSectionResult_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new StrengthStabilityPointConstructionSectionResultEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullStrengthStabilityPointConstructionSectionResultEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new StrengthStabilityPointConstructionFailureMechanismSectionResult(new TestFailureMechanismSection())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] public void Register_WithNullHydraulicLocationEntity_ThrowsArgumentNullException() { // Setup @@ -1810,120 +1122,6 @@ } [Test] - public void Register_WithNullCalculationGroupEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new CalculationGroup()); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullCalculationGroup_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new CalculationGroupEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullPipingCalculationEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new PipingCalculationScenario(new GeneralPipingInput())); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullPipingCalculationScenario_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new PipingCalculationEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullPipingCalculationOutputEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new PipingOutput(1, 1, 1, 1, 1, 1)); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullPipingOutput_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new PipingCalculationOutputEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullPipingSemiProbabilisticOutputEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - PipingSemiProbabilisticOutput output = new PipingSemiProbabilisticOutput(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); - - // Call - TestDelegate test = () => registry.Register(null, output); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullPipingSemiProbabilisticOutput_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new PipingSemiProbabilisticOutputEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] public void Register_WithNullStochasticSoilModelEntity_ThrowsArgumentNullException() { // Setup @@ -2010,2318 +1208,6 @@ Assert.AreEqual("model", paramName); } - [Test] - public void Register_WithNullSoilLayerEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(null, new PipingSoilLayer(0)); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullPipingSoilLayer_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate test = () => registry.Register(new SoilLayerEntity(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullCharacteristicPointEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate call = () => registry.Register(null, new Point3D(1.1, 2.2, 3.3)); - - // Assert - var paramName = Assert.Throws(call).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullPoint3DForCharacteristicPoint_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate call = () => registry.Register(new CharacteristicPointEntity(), null); - - // Assert - var paramName = Assert.Throws(call).ParamName; - Assert.AreEqual("model", paramName); - } - - [Test] - public void Register_WithNullPipingFailureMechanismMetaEntity_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate call = () => registry.Register(null, new PipingProbabilityAssessmentInput()); - - // Assert - var paramName = Assert.Throws(call).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Register_WithNullPipingProbabilityAssessmentInput_ThrowsArgumentNullException() - { - // Setup - var registry = new PersistenceRegistry(); - - // Call - TestDelegate call = () => registry.Register(new PipingFailureMechanismMetaEntity(), null); - - // Assert - var paramName = Assert.Throws(call).ParamName; - Assert.AreEqual("model", paramName); - } - #endregion - - #region TransferIds method - - [Test] - public void TransferIds_WithProjectEntityAdded_EqualProjectEntityIdAndProjectStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new ProjectEntity - { - ProjectEntityId = storageId - }; - var model = new RingtoetsProject(); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithAssessmentSectionEntityAdded_EqualAssessmentSectionEntityIdAndAssessmentSectionStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new AssessmentSectionEntity - { - AssessmentSectionEntityId = storageId - }; - var model = new AssessmentSection(AssessmentSectionComposition.Dike); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithFailureMechanismEntityAddedWithPipingFailureMechanism_EqualFailureMechanismEntityIdAndPipingFailureMechanismStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new FailureMechanismEntity - { - FailureMechanismEntityId = storageId - }; - var model = new PipingFailureMechanism(); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithFailureMechanismEntityAddedWithStandAloneFailureMechanism_EqualFailureMechanismEntityIdAndStandAloneFailureMechanismStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new FailureMechanismEntity - { - FailureMechanismEntityId = storageId - }; - var model = new MacrostabilityInwardsFailureMechanism(); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithFailureMechanismSectionEntityAddedWithFailureMechanismSection_EqualFailureMechanismSectionEntityIdAndFailureMechanismSectionStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new FailureMechanismSectionEntity - { - FailureMechanismSectionEntityId = storageId - }; - var model = new TestFailureMechanismSection(); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithPipingSectionResultEntityAddedWithPipingFailureMechanismSectionResult_EqualPipingSectionEntityIdAndPipingFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new PipingSectionResultEntity - { - PipingSectionResultEntityId = storageId - }; - var model = new PipingFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithGrassCoverErosionInwardsFailureMechanismMetaEntityAddedWithGeneralGrassCoverErosionInwardsInput_EqualGrassCoverErosionInwardsFailureMechanismMetaEntityIdAndGeneralGrassCoverErosionInwardsInputStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new GrassCoverErosionInwardsFailureMechanismMetaEntity - { - GrassCoverErosionInwardsFailureMechanismMetaEntityId = storageId - }; - var model = new GeneralGrassCoverErosionInwardsInput(); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithDikeProfileEntityAddedWithDikeProfile_EqualDikeProfileEntityIdAndDikeProfileStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new DikeProfileEntity - { - DikeProfileEntityId = storageId - }; - DikeProfile model = CreateDikeProfile(); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithGrassCoverErosionInwardsCalculationEntityAddedWithGrassCoverErosionInwardsCalculation_EqualGrassCoverErosionInwardsCalculationEntityIdAndGrassCoverErosionInwardsCalculationStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new GrassCoverErosionInwardsCalculationEntity - { - GrassCoverErosionInwardsCalculationEntityId = storageId - }; - var model = new GrassCoverErosionInwardsCalculation(); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithGrassCoverErosionInwardsOutputEntityAddedWithGrassCoverErosionInwardsOutput_EqualGrassCoverErosionInwardsOutputEntityIdAndGrassCoverErosionInwardsOutputStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new GrassCoverErosionInwardsOutputEntity - { - GrassCoverErosionInwardsOutputEntityId = storageId - }; - var model = new GrassCoverErosionInwardsOutput(1, false, new ProbabilityAssessmentOutput(1, 1, 1, 1, 1), 1); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithProbabilisticOutputEntityAddedWithGrassCoverErosionInwardsOutput_EqualProbabilisticOutputEntityIdAndGrassCoverErosionInwardsOutputProbabilityAssessmentOutputStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new ProbabilisticOutputEntity - { - ProbabilisticOutputEntityId = storageId - }; - var model = new ProbabilityAssessmentOutput(1, 1, 1, 1, 1); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithGrassCoverErosionInwardsSectionResultEntityAddedWithGrassCoverErosionInwardsFailureMechanismSectionResult_EqualGrassCoverErosionInwardsSectionEntityIdAndGrassCoverErosionInwardsFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new GrassCoverErosionInwardsSectionResultEntity - { - GrassCoverErosionInwardsSectionResultEntityId = storageId - }; - var model = new GrassCoverErosionInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithHeightStructuresSectionResultEntityAddedWithHeightStructuresFailureMechanismSectionResult_EqualHeightStructuresSectionEntityIdAndHeightStructuresFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new HeightStructuresSectionResultEntity - { - HeightStructuresSectionResultEntityId = storageId - }; - var model = new HeightStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithStrengthStabilityLengthwiseConstructionSectionResultEntityAddedWithStrengthStabilityLengthwiseConstructionFailureMechanismSectionResult_EqualStrengthStabilityLengthwiseConstructionSectionEntityIdAndStrengthStabilityLengthwiseConstructionFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new StrengthStabilityLengthwiseConstructionSectionResultEntity - { - StrengthStabilityLengthwiseConstructionSectionResultEntityId = storageId - }; - var model = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithTechnicalInnovationSectionResultEntityAddedWithTechnicalInnovationFailureMechanismSectionResult_EqualTechnicalInnovationSectionEntityIdAndTechnicalInnovationFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new TechnicalInnovationSectionResultEntity - { - TechnicalInnovationSectionResultEntityId = storageId - }; - var model = new TechnicalInnovationFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithWaterPressureAsphaltCoverSectionResultEntityAddedWithWaterPressureAsphaltCoverFailureMechanismSectionResult_EqualWaterPressureAsphaltCoverSectionEntityIdAndWaterPressureAsphaltCoverFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new WaterPressureAsphaltCoverSectionResultEntity - { - WaterPressureAsphaltCoverSectionResultEntityId = storageId - }; - var model = new WaterPressureAsphaltCoverFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithClosingStructureSectionResultEntityAddedWithClosingStructureFailureMechanismSectionResult_EqualClosingStructureSectionEntityIdAndClosingStructureFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new ClosingStructureSectionResultEntity - { - ClosingStructureSectionResultEntityId = storageId - }; - var model = new ClosingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithMacrostabilityInwardsSectionResultEntityAddedWithMacrostabilityInwardsFailureMechanismSectionResult_EqualMacrostabilityInwardsSectionEntityIdAndMacrostabilityInwardsFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new MacrostabilityInwardsSectionResultEntity - { - MacrostabilityInwardsSectionResultEntityId = storageId - }; - var model = new MacrostabilityInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithMacrostabilityOutwardsSectionResultEntityAddedWithMacrostabilityOutwardsFailureMechanismSectionResult_EqualMacrostabilityOutwardsSectionEntityIdAndMacrostabilityOutwardsFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new MacrostabilityOutwardsSectionResultEntity - { - MacrostabilityOutwardsSectionResultEntityId = storageId - }; - var model = new MacrostabilityOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithWaveImpactAsphaltCoverSectionResultEntityAddedWithWaveImpactAsphaltCoverFailureMechanismSectionResult_EqualWaveImpactAsphaltCoverSectionEntityIdAndWaveImpactAsphaltCoverFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new WaveImpactAsphaltCoverSectionResultEntity - { - WaveImpactAsphaltCoverSectionResultEntityId = storageId - }; - var model = new WaveImpactAsphaltCoverFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithGrassCoverErosionOutwardsSectionResultEntityAddedWithGrassCoverErosionOutwardsFailureMechanismSectionResult_EqualGrassCoverErosionOutwardsSectionEntityIdAndGrassCoverErosionOutwardsFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new GrassCoverErosionOutwardsSectionResultEntity - { - GrassCoverErosionOutwardsSectionResultEntityId = storageId - }; - var model = new GrassCoverErosionOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithGrassCoverSlipOffInwardsSectionResultEntityAddedWithGrassCoverSlipOffInwardsFailureMechanismSectionResult_EqualGrassCoverSlipOffInwardsSectionEntityIdAndGrassCoverSlipOffInwardsFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new GrassCoverSlipOffInwardsSectionResultEntity - { - GrassCoverSlipOffInwardsSectionResultEntityId = storageId - }; - var model = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithGrassCoverSlipOffOutwardsSectionResultEntityAddedWithGrassCoverSlipOffOutwardsFailureMechanismSectionResult_EqualGrassCoverSlipOffOutwardsSectionEntityIdAndGrassCoverSlipOffOutwardsFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new GrassCoverSlipOffOutwardsSectionResultEntity - { - GrassCoverSlipOffOutwardsSectionResultEntityId = storageId - }; - var model = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithMicrostabilitySectionResultEntityAddedWithMicrostabilityFailureMechanismSectionResult_EqualMicrostabilitySectionEntityIdAndMicrostabilityFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new MicrostabilitySectionResultEntity - { - MicrostabilitySectionResultEntityId = storageId - }; - var model = new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithPipingStructureSectionResultEntityAddedWithPipingStructureFailureMechanismSectionResult_EqualPipingStructureSectionEntityIdAndPipingStructureFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new PipingStructureSectionResultEntity - { - PipingStructureSectionResultEntityId = storageId - }; - var model = new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithDuneErosionSectionResultEntityAddedWithDuneErosionFailureMechanismSectionResult_EqualDuneErosionSectionEntityIdAndDuneErosionFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new DuneErosionSectionResultEntity - { - DuneErosionSectionResultEntityId = storageId - }; - var model = new DuneErosionFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithStabilityStoneCoverSectionResultEntityAddedWithStabilityStoneCoverFailureMechanismSectionResult_EqualStabilityStoneCoverSectionEntityIdAndStabilityStoneCoverFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new StabilityStoneCoverSectionResultEntity - { - StabilityStoneCoverSectionResultEntityId = storageId - }; - var model = new StabilityStoneCoverFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithStrengthStabilityPointConstructionSectionResultEntityAddedWithStrengthStabilityPointConstructionFailureMechanismSectionResult_EqualStrengthStabilityPointConstructionSectionEntityIdAndStrengthStabilityPointConstructionFailureMechanismSectionResultStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new StrengthStabilityPointConstructionSectionResultEntity - { - StrengthStabilityPointConstructionSectionResultEntityId = storageId - }; - var model = new StrengthStabilityPointConstructionFailureMechanismSectionResult(new TestFailureMechanismSection()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithHydraulicLocationEntityAdded_EqualHydraulicLocationEntityIdAndHydraulicBoundaryLocationStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new HydraulicLocationEntity - { - HydraulicLocationEntityId = storageId - }; - var model = new HydraulicBoundaryLocation(-1, "name", 0, 0); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithCalculationGroupEntityAdded_EqualCalculationGroupEntityIdAndCalculationGroupStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new CalculationGroupEntity - { - CalculationGroupEntityId = storageId - }; - var model = new CalculationGroup(); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithPipingCalculationEntityAdded_EqualPipingCalculationEntityIdAndPipingCalculationScenarioStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new PipingCalculationEntity - { - PipingCalculationEntityId = storageId - }; - var model = new PipingCalculationScenario(new GeneralPipingInput()); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithPipingCalculationOutputEntityAdded_EqualPipingCalculationOutputEntityIdAndPipingOutputStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new PipingCalculationOutputEntity - { - PipingCalculationOutputEntityId = storageId - }; - var model = new PipingOutput(1, 2, 3, 4, 5, 6); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithPipingSemiProbabilisticOutputEntityAdded_EqualPipingSemiProbabilisticOutputEntityIdAndPipingSemiProbabilisticOutputStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new PipingSemiProbabilisticOutputEntity - { - PipingSemiProbabilisticOutputEntityId = storageId - }; - var model = new PipingSemiProbabilisticOutput(2, 0.3, 4, 5, 0.6, 7, 8, 0.9, 1.0, 11, 0.3, 13, 14); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithStochasticSoilModelEntityAdded_EqualStochasticSoilModelEntityIdAndStochasticSoilModelStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new StochasticSoilModelEntity - { - StochasticSoilModelEntityId = storageId - }; - var model = new StochasticSoilModel(-1, "name", "name"); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithStochasticSoilProfileEntityAdded_EqualStochasticSoilProfileEntityIdAndStochasticSoilProfileStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new StochasticSoilProfileEntity - { - StochasticSoilProfileEntityId = storageId - }; - var model = new StochasticSoilProfile(1, SoilProfileType.SoilProfile1D, -1); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithSoilProfileEntityAdded_EqualSoilProfileEntityIdAndPipingSoilProfileStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new SoilProfileEntity - { - SoilProfileEntityId = storageId - }; - var model = new PipingSoilProfile("name", 0, new[] - { - new PipingSoilLayer(1) - }, SoilProfileType.SoilProfile1D, -1); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithSoilLayerEntityAdded_EqualSoilLayerEntityIdAndPipingSoilLayerStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new SoilLayerEntity - { - SoilLayerEntityId = storageId - }; - var model = new PipingSoilLayer(0); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithSurfaceLineEntityAdded_EqualSurfaceLineEntityIdAndRingtoetsPipingSurfaceLineStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new SurfaceLineEntity - { - SurfaceLineEntityId = storageId - }; - var model = new RingtoetsPipingSurfaceLine(); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - [Test] - public void TransferIds_WithPipingFailureMechanismMetaEntityAdded_EqualFailureMechanismMetaEntityIdAndPipingProbabilityAssessmentInputStorageId() - { - // Setup - var registry = new PersistenceRegistry(); - - long storageId = new Random(21).Next(1, 4000); - var entity = new PipingFailureMechanismMetaEntity - { - PipingFailureMechanismMetaEntityId = storageId - }; - var model = new PipingProbabilityAssessmentInput(); - registry.Register(entity, model); - - // Call - registry.TransferIds(); - - // Assert - Assert.AreEqual(storageId, model.StorageId); - } - - #endregion - - #region RemoveUntouched method - - [Test] - public void RemoveUntouched_ProjectEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new ProjectEntity - { - ProjectEntityId = 1 - }; - var persistentEntity = new ProjectEntity - { - ProjectEntityId = 2 - }; - dbContext.ProjectEntities.Add(orphanedEntity); - dbContext.ProjectEntities.Add(persistentEntity); - - var project = new RingtoetsProject - { - StorageId = persistentEntity.ProjectEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, project); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.ProjectEntities.Count()); - CollectionAssert.Contains(dbContext.ProjectEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_AssessmentSectionEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new AssessmentSectionEntity - { - AssessmentSectionEntityId = 1 - }; - var persistentEntity = new AssessmentSectionEntity - { - AssessmentSectionEntityId = 2 - }; - dbContext.AssessmentSectionEntities.Add(orphanedEntity); - dbContext.AssessmentSectionEntities.Add(persistentEntity); - - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) - { - StorageId = persistentEntity.AssessmentSectionEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, assessmentSection); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.AssessmentSectionEntities.Count()); - CollectionAssert.Contains(dbContext.AssessmentSectionEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_FailureMechanismEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - var failureMechanismStub = mocks.Stub(); - mocks.ReplayAll(); - - var orphanedEntity = new FailureMechanismEntity - { - FailureMechanismEntityId = 1 - }; - var persistentEntity = new FailureMechanismEntity - { - FailureMechanismEntityId = 2 - }; - dbContext.FailureMechanismEntities.Add(orphanedEntity); - dbContext.FailureMechanismEntities.Add(persistentEntity); - - failureMechanismStub.StorageId = persistentEntity.FailureMechanismEntityId; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, failureMechanismStub); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.FailureMechanismEntities.Count()); - CollectionAssert.Contains(dbContext.FailureMechanismEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_FailureMechanismSectionEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new FailureMechanismSectionEntity - { - FailureMechanismSectionEntityId = 1 - }; - var persistentEntity = new FailureMechanismSectionEntity - { - FailureMechanismSectionEntityId = 2 - }; - dbContext.FailureMechanismSectionEntities.Add(orphanedEntity); - dbContext.FailureMechanismSectionEntities.Add(persistentEntity); - - var section = new TestFailureMechanismSection - { - StorageId = persistentEntity.FailureMechanismSectionEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.FailureMechanismSectionEntities.Count()); - CollectionAssert.Contains(dbContext.FailureMechanismSectionEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_PipingSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new PipingSectionResultEntity - { - PipingSectionResultEntityId = 1 - }; - var persistentEntity = new PipingSectionResultEntity - { - PipingSectionResultEntityId = 2 - }; - dbContext.PipingSectionResultEntities.Add(orphanedEntity); - dbContext.PipingSectionResultEntities.Add(persistentEntity); - - var section = new PipingFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.PipingSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.PipingSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.PipingSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_GrassCoverErosionInwardsFailureMechanismMetaEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new GrassCoverErosionInwardsFailureMechanismMetaEntity - { - GrassCoverErosionInwardsFailureMechanismMetaEntityId = 1 - }; - var persistentEntity = new GrassCoverErosionInwardsFailureMechanismMetaEntity - { - GrassCoverErosionInwardsFailureMechanismMetaEntityId = 2 - }; - dbContext.GrassCoverErosionInwardsFailureMechanismMetaEntities.Add(orphanedEntity); - dbContext.GrassCoverErosionInwardsFailureMechanismMetaEntities.Add(persistentEntity); - - var section = new GeneralGrassCoverErosionInwardsInput - { - StorageId = persistentEntity.GrassCoverErosionInwardsFailureMechanismMetaEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.GrassCoverErosionInwardsFailureMechanismMetaEntities.Count()); - CollectionAssert.Contains(dbContext.GrassCoverErosionInwardsFailureMechanismMetaEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_DikeProfileEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new DikeProfileEntity - { - DikeProfileEntityId = 1 - }; - var persistentEntity = new DikeProfileEntity - { - DikeProfileEntityId = 2 - }; - dbContext.DikeProfileEntities.Add(orphanedEntity); - dbContext.DikeProfileEntities.Add(persistentEntity); - - DikeProfile section = CreateDikeProfile(); - section.StorageId = persistentEntity.DikeProfileEntityId; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.DikeProfileEntities.Count()); - CollectionAssert.Contains(dbContext.DikeProfileEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_GrassCoverErosionInwardsCalculationEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new GrassCoverErosionInwardsCalculationEntity - { - GrassCoverErosionInwardsCalculationEntityId = 1 - }; - var persistentEntity = new GrassCoverErosionInwardsCalculationEntity - { - GrassCoverErosionInwardsCalculationEntityId = 2 - }; - dbContext.GrassCoverErosionInwardsCalculationEntities.Add(orphanedEntity); - dbContext.GrassCoverErosionInwardsCalculationEntities.Add(persistentEntity); - - var calculation = new GrassCoverErosionInwardsCalculation - { - StorageId = persistentEntity.GrassCoverErosionInwardsCalculationEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, calculation); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.GrassCoverErosionInwardsCalculationEntities.Count()); - CollectionAssert.Contains(dbContext.GrassCoverErosionInwardsCalculationEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_GrassCoverErosionInwardsOutputEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new GrassCoverErosionInwardsOutputEntity - { - GrassCoverErosionInwardsOutputEntityId = 1 - }; - var persistentEntity = new GrassCoverErosionInwardsOutputEntity - { - GrassCoverErosionInwardsOutputEntityId = 2 - }; - dbContext.GrassCoverErosionInwardsOutputEntities.Add(orphanedEntity); - dbContext.GrassCoverErosionInwardsOutputEntities.Add(persistentEntity); - - var calculation = new GrassCoverErosionInwardsOutput(1, false, new ProbabilityAssessmentOutput(1, 1, 1, 1, 1), 1) - { - StorageId = persistentEntity.GrassCoverErosionInwardsOutputEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, calculation); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.GrassCoverErosionInwardsOutputEntities.Count()); - CollectionAssert.Contains(dbContext.GrassCoverErosionInwardsOutputEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_ProbabilisticOutputEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new ProbabilisticOutputEntity - { - ProbabilisticOutputEntityId = 1 - }; - var persistentEntity = new ProbabilisticOutputEntity - { - ProbabilisticOutputEntityId = 2 - }; - dbContext.ProbabilisticOutputEntities.Add(orphanedEntity); - dbContext.ProbabilisticOutputEntities.Add(persistentEntity); - - var calculation = new ProbabilityAssessmentOutput(1, 1, 1, 1, 1) - { - StorageId = persistentEntity.ProbabilisticOutputEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, calculation); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.ProbabilisticOutputEntities.Count()); - CollectionAssert.Contains(dbContext.ProbabilisticOutputEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_GrassCoverErosionInwardsSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new GrassCoverErosionInwardsSectionResultEntity - { - GrassCoverErosionInwardsSectionResultEntityId = 1 - }; - var persistentEntity = new GrassCoverErosionInwardsSectionResultEntity - { - GrassCoverErosionInwardsSectionResultEntityId = 2 - }; - dbContext.GrassCoverErosionInwardsSectionResultEntities.Add(orphanedEntity); - dbContext.GrassCoverErosionInwardsSectionResultEntities.Add(persistentEntity); - - var section = new GrassCoverErosionInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.GrassCoverErosionInwardsSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.GrassCoverErosionInwardsSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.GrassCoverErosionInwardsSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_HeightStructuresSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new HeightStructuresSectionResultEntity - { - HeightStructuresSectionResultEntityId = 1 - }; - var persistentEntity = new HeightStructuresSectionResultEntity - { - HeightStructuresSectionResultEntityId = 2 - }; - dbContext.HeightStructuresSectionResultEntities.Add(orphanedEntity); - dbContext.HeightStructuresSectionResultEntities.Add(persistentEntity); - - var section = new HeightStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.HeightStructuresSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.HeightStructuresSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.HeightStructuresSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_StrengthStabilityLengthwiseConstructionSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new StrengthStabilityLengthwiseConstructionSectionResultEntity - { - StrengthStabilityLengthwiseConstructionSectionResultEntityId = 1 - }; - var persistentEntity = new StrengthStabilityLengthwiseConstructionSectionResultEntity - { - StrengthStabilityLengthwiseConstructionSectionResultEntityId = 2 - }; - dbContext.StrengthStabilityLengthwiseConstructionSectionResultEntities.Add(orphanedEntity); - dbContext.StrengthStabilityLengthwiseConstructionSectionResultEntities.Add(persistentEntity); - - var section = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.StrengthStabilityLengthwiseConstructionSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.StrengthStabilityLengthwiseConstructionSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.StrengthStabilityLengthwiseConstructionSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_TechnicalInnovationSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new TechnicalInnovationSectionResultEntity - { - TechnicalInnovationSectionResultEntityId = 1 - }; - var persistentEntity = new TechnicalInnovationSectionResultEntity - { - TechnicalInnovationSectionResultEntityId = 2 - }; - dbContext.TechnicalInnovationSectionResultEntities.Add(orphanedEntity); - dbContext.TechnicalInnovationSectionResultEntities.Add(persistentEntity); - - var section = new TechnicalInnovationFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.TechnicalInnovationSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.TechnicalInnovationSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.TechnicalInnovationSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_WaterPressureAsphaltCoverSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new WaterPressureAsphaltCoverSectionResultEntity - { - WaterPressureAsphaltCoverSectionResultEntityId = 1 - }; - var persistentEntity = new WaterPressureAsphaltCoverSectionResultEntity - { - WaterPressureAsphaltCoverSectionResultEntityId = 2 - }; - dbContext.WaterPressureAsphaltCoverSectionResultEntities.Add(orphanedEntity); - dbContext.WaterPressureAsphaltCoverSectionResultEntities.Add(persistentEntity); - - var section = new WaterPressureAsphaltCoverFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.WaterPressureAsphaltCoverSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.WaterPressureAsphaltCoverSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.WaterPressureAsphaltCoverSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_ClosingStructureSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new ClosingStructureSectionResultEntity - { - ClosingStructureSectionResultEntityId = 1 - }; - var persistentEntity = new ClosingStructureSectionResultEntity - { - ClosingStructureSectionResultEntityId = 2 - }; - dbContext.ClosingStructureSectionResultEntities.Add(orphanedEntity); - dbContext.ClosingStructureSectionResultEntities.Add(persistentEntity); - - var section = new ClosingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.ClosingStructureSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.ClosingStructureSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.ClosingStructureSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_MacrostabilityInwardsSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new MacrostabilityInwardsSectionResultEntity - { - MacrostabilityInwardsSectionResultEntityId = 1 - }; - var persistentEntity = new MacrostabilityInwardsSectionResultEntity - { - MacrostabilityInwardsSectionResultEntityId = 2 - }; - dbContext.MacrostabilityInwardsSectionResultEntities.Add(orphanedEntity); - dbContext.MacrostabilityInwardsSectionResultEntities.Add(persistentEntity); - - var section = new MacrostabilityInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.MacrostabilityInwardsSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.MacrostabilityInwardsSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.MacrostabilityInwardsSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_MacrostabilityOutwardsSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new MacrostabilityOutwardsSectionResultEntity - { - MacrostabilityOutwardsSectionResultEntityId = 1 - }; - var persistentEntity = new MacrostabilityOutwardsSectionResultEntity - { - MacrostabilityOutwardsSectionResultEntityId = 2 - }; - dbContext.MacrostabilityOutwardsSectionResultEntities.Add(orphanedEntity); - dbContext.MacrostabilityOutwardsSectionResultEntities.Add(persistentEntity); - - var section = new MacrostabilityOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.MacrostabilityOutwardsSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.MacrostabilityOutwardsSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.MacrostabilityOutwardsSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_WaveImpactAsphaltCoverSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new WaveImpactAsphaltCoverSectionResultEntity - { - WaveImpactAsphaltCoverSectionResultEntityId = 1 - }; - var persistentEntity = new WaveImpactAsphaltCoverSectionResultEntity - { - WaveImpactAsphaltCoverSectionResultEntityId = 2 - }; - dbContext.WaveImpactAsphaltCoverSectionResultEntities.Add(orphanedEntity); - dbContext.WaveImpactAsphaltCoverSectionResultEntities.Add(persistentEntity); - - var section = new WaveImpactAsphaltCoverFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.WaveImpactAsphaltCoverSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.WaveImpactAsphaltCoverSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.WaveImpactAsphaltCoverSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_GrassCoverErosionOutwardsSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new GrassCoverErosionOutwardsSectionResultEntity - { - GrassCoverErosionOutwardsSectionResultEntityId = 1 - }; - var persistentEntity = new GrassCoverErosionOutwardsSectionResultEntity - { - GrassCoverErosionOutwardsSectionResultEntityId = 2 - }; - dbContext.GrassCoverErosionOutwardsSectionResultEntities.Add(orphanedEntity); - dbContext.GrassCoverErosionOutwardsSectionResultEntities.Add(persistentEntity); - - var section = new GrassCoverErosionOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.GrassCoverErosionOutwardsSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.GrassCoverErosionOutwardsSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.GrassCoverErosionOutwardsSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_GrassCoverSlipOffInwardsSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new GrassCoverSlipOffInwardsSectionResultEntity - { - GrassCoverSlipOffInwardsSectionResultEntityId = 1 - }; - var persistentEntity = new GrassCoverSlipOffInwardsSectionResultEntity - { - GrassCoverSlipOffInwardsSectionResultEntityId = 2 - }; - dbContext.GrassCoverSlipOffInwardsSectionResultEntities.Add(orphanedEntity); - dbContext.GrassCoverSlipOffInwardsSectionResultEntities.Add(persistentEntity); - - var section = new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.GrassCoverSlipOffInwardsSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.GrassCoverSlipOffInwardsSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.GrassCoverSlipOffInwardsSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_GrassCoverSlipOffOutwardsSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new GrassCoverSlipOffOutwardsSectionResultEntity - { - GrassCoverSlipOffOutwardsSectionResultEntityId = 1 - }; - var persistentEntity = new GrassCoverSlipOffOutwardsSectionResultEntity - { - GrassCoverSlipOffOutwardsSectionResultEntityId = 2 - }; - dbContext.GrassCoverSlipOffOutwardsSectionResultEntities.Add(orphanedEntity); - dbContext.GrassCoverSlipOffOutwardsSectionResultEntities.Add(persistentEntity); - - var section = new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.GrassCoverSlipOffOutwardsSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.GrassCoverSlipOffOutwardsSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.GrassCoverSlipOffOutwardsSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_MicrostabilitySectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new MicrostabilitySectionResultEntity - { - MicrostabilitySectionResultEntityId = 1 - }; - var persistentEntity = new MicrostabilitySectionResultEntity - { - MicrostabilitySectionResultEntityId = 2 - }; - dbContext.MicrostabilitySectionResultEntities.Add(orphanedEntity); - dbContext.MicrostabilitySectionResultEntities.Add(persistentEntity); - - var section = new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.MicrostabilitySectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.MicrostabilitySectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.MicrostabilitySectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_PipingStructureSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new PipingStructureSectionResultEntity - { - PipingStructureSectionResultEntityId = 1 - }; - var persistentEntity = new PipingStructureSectionResultEntity - { - PipingStructureSectionResultEntityId = 2 - }; - dbContext.PipingStructureSectionResultEntities.Add(orphanedEntity); - dbContext.PipingStructureSectionResultEntities.Add(persistentEntity); - - var section = new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.PipingStructureSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.PipingStructureSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.PipingStructureSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_DuneErosionSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new DuneErosionSectionResultEntity - { - DuneErosionSectionResultEntityId = 1 - }; - var persistentEntity = new DuneErosionSectionResultEntity - { - DuneErosionSectionResultEntityId = 2 - }; - dbContext.DuneErosionSectionResultEntities.Add(orphanedEntity); - dbContext.DuneErosionSectionResultEntities.Add(persistentEntity); - - var section = new DuneErosionFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.DuneErosionSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.DuneErosionSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.DuneErosionSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_StabilityStoneCoverSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new StabilityStoneCoverSectionResultEntity - { - StabilityStoneCoverSectionResultEntityId = 1 - }; - var persistentEntity = new StabilityStoneCoverSectionResultEntity - { - StabilityStoneCoverSectionResultEntityId = 2 - }; - dbContext.StabilityStoneCoverSectionResultEntities.Add(orphanedEntity); - dbContext.StabilityStoneCoverSectionResultEntities.Add(persistentEntity); - - var section = new StabilityStoneCoverFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.StabilityStoneCoverSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.StabilityStoneCoverSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.StabilityStoneCoverSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_StrengthStabilityPointConstructionSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new StrengthStabilityPointConstructionSectionResultEntity - { - StrengthStabilityPointConstructionSectionResultEntityId = 1 - }; - var persistentEntity = new StrengthStabilityPointConstructionSectionResultEntity - { - StrengthStabilityPointConstructionSectionResultEntityId = 2 - }; - dbContext.StrengthStabilityPointConstructionSectionResultEntities.Add(orphanedEntity); - dbContext.StrengthStabilityPointConstructionSectionResultEntities.Add(persistentEntity); - - var section = new StrengthStabilityPointConstructionFailureMechanismSectionResult(new TestFailureMechanismSection()) - { - StorageId = persistentEntity.StrengthStabilityPointConstructionSectionResultEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, section); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.StrengthStabilityPointConstructionSectionResultEntities.Count()); - CollectionAssert.Contains(dbContext.StrengthStabilityPointConstructionSectionResultEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_HydraulicLocationEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new HydraulicLocationEntity - { - HydraulicLocationEntityId = 1 - }; - var persistentEntity = new HydraulicLocationEntity - { - HydraulicLocationEntityId = 2 - }; - dbContext.HydraulicLocationEntities.Add(orphanedEntity); - dbContext.HydraulicLocationEntities.Add(persistentEntity); - - var boundaryLocation = new HydraulicBoundaryLocation(123, "A", 1, 2) - { - StorageId = persistentEntity.HydraulicLocationEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, boundaryLocation); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.HydraulicLocationEntities.Count()); - CollectionAssert.Contains(dbContext.HydraulicLocationEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_CalculationGroupEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new CalculationGroupEntity - { - CalculationGroupEntityId = 1 - }; - var persistentEntity = new CalculationGroupEntity - { - CalculationGroupEntityId = 2 - }; - dbContext.CalculationGroupEntities.Add(orphanedEntity); - dbContext.CalculationGroupEntities.Add(persistentEntity); - - var calculationGroup = new CalculationGroup - { - StorageId = persistentEntity.CalculationGroupEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, calculationGroup); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.CalculationGroupEntities.Count()); - CollectionAssert.Contains(dbContext.CalculationGroupEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_PipingCalculationEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new PipingCalculationEntity - { - PipingCalculationEntityId = 1 - }; - var persistentEntity = new PipingCalculationEntity - { - PipingCalculationEntityId = 2 - }; - dbContext.PipingCalculationEntities.Add(orphanedEntity); - dbContext.PipingCalculationEntities.Add(persistentEntity); - - var calculation = new PipingCalculationScenario(new GeneralPipingInput()) - { - StorageId = persistentEntity.PipingCalculationEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, calculation); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.PipingCalculationEntities.Count()); - CollectionAssert.Contains(dbContext.PipingCalculationEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_PipingCalculationOutputEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new PipingCalculationOutputEntity - { - PipingCalculationOutputEntityId = 1 - }; - var persistentEntity = new PipingCalculationOutputEntity - { - PipingCalculationOutputEntityId = 2 - }; - dbContext.PipingCalculationOutputEntities.Add(orphanedEntity); - dbContext.PipingCalculationOutputEntities.Add(persistentEntity); - - var pipingOutput = new PipingOutput(1, 2, 3, 4, 5, 6) - { - StorageId = persistentEntity.PipingCalculationOutputEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, pipingOutput); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.PipingCalculationOutputEntities.Count()); - CollectionAssert.Contains(dbContext.PipingCalculationOutputEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_PipingSemiProbabilisticOutputEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new PipingSemiProbabilisticOutputEntity - { - PipingSemiProbabilisticOutputEntityId = 1 - }; - var persistentEntity = new PipingSemiProbabilisticOutputEntity - { - PipingSemiProbabilisticOutputEntityId = 2 - }; - dbContext.PipingSemiProbabilisticOutputEntities.Add(orphanedEntity); - dbContext.PipingSemiProbabilisticOutputEntities.Add(persistentEntity); - - var pipingSemiProbabilisticOutput = new PipingSemiProbabilisticOutput(2, 0.3, 4, 5, 0.6, 7, - 8, 0.9, 1.0, 11, 0.3, 13, 14) - { - StorageId = persistentEntity.PipingSemiProbabilisticOutputEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, pipingSemiProbabilisticOutput); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.PipingSemiProbabilisticOutputEntities.Count()); - CollectionAssert.Contains(dbContext.PipingSemiProbabilisticOutputEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_StochasticSoilModelEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new StochasticSoilModelEntity - { - StochasticSoilModelEntityId = 1 - }; - var persistentEntity = new StochasticSoilModelEntity - { - StochasticSoilModelEntityId = 2 - }; - dbContext.StochasticSoilModelEntities.Add(orphanedEntity); - dbContext.StochasticSoilModelEntities.Add(persistentEntity); - - var soilModel = new StochasticSoilModel(123, "A", "B") - { - StorageId = persistentEntity.StochasticSoilModelEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, soilModel); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.StochasticSoilModelEntities.Count()); - CollectionAssert.Contains(dbContext.StochasticSoilModelEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_StochasticSoilProfileEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new StochasticSoilProfileEntity - { - StochasticSoilProfileEntityId = 1 - }; - var persistentEntity = new StochasticSoilProfileEntity - { - StochasticSoilProfileEntityId = 2 - }; - dbContext.StochasticSoilProfileEntities.Add(orphanedEntity); - dbContext.StochasticSoilProfileEntities.Add(persistentEntity); - - var stochasticSoilProfile = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 123) - { - StorageId = persistentEntity.StochasticSoilProfileEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, stochasticSoilProfile); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.StochasticSoilProfileEntities.Count()); - CollectionAssert.Contains(dbContext.StochasticSoilProfileEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_SoilProfileEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new SoilProfileEntity - { - SoilProfileEntityId = 1 - }; - var persistentEntity = new SoilProfileEntity - { - SoilProfileEntityId = 2 - }; - dbContext.SoilProfileEntities.Add(orphanedEntity); - dbContext.SoilProfileEntities.Add(persistentEntity); - - var soilProfile = new TestPipingSoilProfile - { - StorageId = persistentEntity.SoilProfileEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, soilProfile); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.SoilProfileEntities.Count()); - CollectionAssert.Contains(dbContext.SoilProfileEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_SoilLayerEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new SoilLayerEntity - { - SoilLayerEntityId = 1 - }; - var persistentEntity = new SoilLayerEntity - { - SoilLayerEntityId = 2 - }; - dbContext.SoilLayerEntities.Add(orphanedEntity); - dbContext.SoilLayerEntities.Add(persistentEntity); - - var soilLayer = new PipingSoilLayer(1) - { - StorageId = persistentEntity.SoilLayerEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, soilLayer); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.SoilLayerEntities.Count()); - CollectionAssert.Contains(dbContext.SoilLayerEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_SurfaceLineEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new SurfaceLineEntity - { - SurfaceLineEntityId = 1 - }; - var persistentEntity = new SurfaceLineEntity - { - SurfaceLineEntityId = 2 - }; - dbContext.SurfaceLineEntities.Add(orphanedEntity); - dbContext.SurfaceLineEntities.Add(persistentEntity); - - var surfaceLine = new RingtoetsPipingSurfaceLine - { - StorageId = persistentEntity.SurfaceLineEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, surfaceLine); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.SurfaceLineEntities.Count()); - CollectionAssert.Contains(dbContext.SurfaceLineEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_CharacteristicPointEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new CharacteristicPointEntity - { - CharacteristicPointEntityId = 1 - }; - var persistentEntity = new CharacteristicPointEntity - { - CharacteristicPointEntityId = 2 - }; - dbContext.CharacteristicPointEntities.Add(orphanedEntity); - dbContext.CharacteristicPointEntities.Add(persistentEntity); - - var geometryPoint = new Point3D(1, 2, 3); - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, geometryPoint); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.CharacteristicPointEntities.Count()); - CollectionAssert.Contains(dbContext.CharacteristicPointEntities, persistentEntity); - mocks.VerifyAll(); - } - - [Test] - public void RemoveUntouched_PipingFailureMechanismMetaEntity_OrphanedEntityIsRemovedFromRingtoetsEntities() - { - // Setup - var mocks = new MockRepository(); - IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks); - mocks.ReplayAll(); - - var orphanedEntity = new PipingFailureMechanismMetaEntity - { - PipingFailureMechanismMetaEntityId = 1 - }; - var persistentEntity = new PipingFailureMechanismMetaEntity - { - PipingFailureMechanismMetaEntityId = 2 - }; - dbContext.PipingFailureMechanismMetaEntities.Add(orphanedEntity); - dbContext.PipingFailureMechanismMetaEntities.Add(persistentEntity); - - var model = new PipingProbabilityAssessmentInput - { - StorageId = persistentEntity.PipingFailureMechanismMetaEntityId - }; - - var registry = new PersistenceRegistry(); - registry.Register(persistentEntity, model); - - // Call - registry.RemoveUntouched(dbContext); - - // Assert - Assert.AreEqual(1, dbContext.PipingFailureMechanismMetaEntities.Count()); - CollectionAssert.Contains(dbContext.PipingFailureMechanismMetaEntities, persistentEntity); - mocks.VerifyAll(); - } - - #endregion } } \ No newline at end of file