public void Read_WithCollectorAnd2dProfile_ReturnsStochasticSoilProfileWithPropertiesSet()
        {
            // Setup
            var random = new Random(21);
            var entity = new MacroStabilityInwardsStochasticSoilProfileEntity
            {
                Probability = random.NextDouble(),
                MacroStabilityInwardsSoilProfileTwoDEntity = new MacroStabilityInwardsSoilProfileTwoDEntity
                {
                    Name = "SoilProfile",
                    MacroStabilityInwardsSoilLayerTwoDEntities =
                    {
                        MacroStabilityInwardsSoilLayerTwoDEntityTestFactory.CreateMacroStabilityInwardsSoilLayerTwoDEntity()
                    }
                }
            };
            var collector = new ReadConversionCollector();

            // Call
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = entity.Read(collector);

            // Assert
            Assert.IsNotNull(stochasticSoilProfile);
            Assert.AreEqual(entity.Probability, stochasticSoilProfile.Probability, 1e-6);

            IMacroStabilityInwardsSoilProfile <IMacroStabilityInwardsSoilLayer> profile = stochasticSoilProfile.SoilProfile;

            Assert.IsInstanceOf <MacroStabilityInwardsSoilProfile2D>(profile);
            Assert.AreEqual(entity.MacroStabilityInwardsSoilProfileTwoDEntity.Name, profile.Name);
        }
        public void GivenReadObject_WhenReadCalledOnSameEntity_ThenSameObjectInstanceReturned()
        {
            // Given
            var entity = new MacroStabilityInwardsStochasticSoilProfileEntity
            {
                MacroStabilityInwardsSoilProfileOneDEntity = new MacroStabilityInwardsSoilProfileOneDEntity
                {
                    Name = "StochasticSoilProfile",
                    MacroStabilityInwardsSoilLayerOneDEntities =
                    {
                        new MacroStabilityInwardsSoilLayerOneDEntity()
                    }
                }
            };

            var collector = new ReadConversionCollector();

            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile1 = entity.Read(collector);

            // When
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile2 = entity.Read(collector);

            // Then
            Assert.AreSame(stochasticSoilProfile1, stochasticSoilProfile2);
        }
コード例 #3
0
        /// <summary>
        /// Tries to assign the stochastic soil profile.
        /// </summary>
        /// <param name="calculationConfiguration">The calculation read from the imported file.</param>
        /// <param name="calculation">The calculation to configure.</param>
        /// <returns><c>false</c> when the <paramref name="calculationConfiguration"/> has:
        /// <list type="bullet">
        /// <item>a <see cref="MacroStabilityInwardsStochasticSoilProfile"/> set but no <see cref="MacroStabilityInwardsStochasticSoilModel"/>
        /// is specified;</item>
        /// <item>a <see cref="MacroStabilityInwardsStochasticSoilProfile"/> set which is not
        ///  available in the <see cref="MacroStabilityInwardsStochasticSoilModel"/>.</item>
        /// </list>
        /// <c>true</c> otherwise.</returns>
        private bool TrySetStochasticSoilProfile(MacroStabilityInwardsCalculationConfiguration calculationConfiguration,
                                                 MacroStabilityInwardsCalculationScenario calculation)
        {
            if (calculationConfiguration.StochasticSoilProfileName == null)
            {
                return(true);
            }

            if (calculation.InputParameters.StochasticSoilModel == null)
            {
                Log.LogCalculationConversionError(string.Format(
                                                      Resources.MacroStabilityInwardsCalculationConfigurationImporter_ReadStochasticSoilProfile_No_soil_model_provided_for_soil_profile_with_name_0,
                                                      calculationConfiguration.StochasticSoilProfileName),
                                                  calculation.Name);
                return(false);
            }

            MacroStabilityInwardsStochasticSoilProfile soilProfile = calculation.InputParameters
                                                                     .StochasticSoilModel
                                                                     .StochasticSoilProfiles
                                                                     .FirstOrDefault(ssp => ssp.SoilProfile.Name == calculationConfiguration.StochasticSoilProfileName);

            if (soilProfile == null)
            {
                Log.LogCalculationConversionError(string.Format(
                                                      Resources.MacroStabilityInwardsCalculationConfigurationImporter_ReadStochasticSoilProfile_Stochastic_soil_profile_0_does_not_exist_within_soil_model_1,
                                                      calculationConfiguration.StochasticSoilProfileName,
                                                      calculationConfiguration.StochasticSoilModelName),
                                                  calculation.Name);
                return(false);
            }

            calculation.InputParameters.StochasticSoilProfile = soilProfile;
            return(true);
        }
        public void Read_DifferentStochasticSoilProfileEntitiesWithSame2dProfile_ReturnsStochasticSoilProfilesWithSameSoilProfile()
        {
            // Setup
            var    random                = new Random(21);
            double probability           = random.NextDouble();
            var    soilProfileTwoDEntity = new MacroStabilityInwardsSoilProfileTwoDEntity
            {
                Name = "SoilProfile",
                MacroStabilityInwardsSoilLayerTwoDEntities =
                {
                    MacroStabilityInwardsSoilLayerTwoDEntityTestFactory.CreateMacroStabilityInwardsSoilLayerTwoDEntity()
                }
            };

            var firstEntity = new MacroStabilityInwardsStochasticSoilProfileEntity
            {
                Probability = probability,
                MacroStabilityInwardsSoilProfileTwoDEntity = soilProfileTwoDEntity
            };
            var secondEntity = new MacroStabilityInwardsStochasticSoilProfileEntity
            {
                Probability = 1 - probability,
                MacroStabilityInwardsSoilProfileTwoDEntity = soilProfileTwoDEntity
            };
            var collector = new ReadConversionCollector();

            MacroStabilityInwardsStochasticSoilProfile firstStochasticSoilProfile = firstEntity.Read(collector);

            // Call
            MacroStabilityInwardsStochasticSoilProfile secondStochasticSoilProfile = secondEntity.Read(collector);

            // Assert
            Assert.AreNotSame(firstStochasticSoilProfile, secondStochasticSoilProfile);
            Assert.AreSame(firstStochasticSoilProfile.SoilProfile, secondStochasticSoilProfile.SoilProfile);
        }
コード例 #5
0
        public void Create_SoilProfileWithPreconsolidationStressOutsideLayers_ReturnsPersistableStates()
        {
            // Setup
            MacroStabilityInwardsCalculationScenario   calculation           = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(new TestHydraulicBoundaryLocation());
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(new[]
            {
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(50, 1))
            });

            calculation.InputParameters.StochasticSoilProfile = stochasticSoilProfile;

            IMacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfile = calculation.InputParameters.SoilProfileUnderSurfaceLine;

            var idFactory = new IdFactory();
            var registry  = new MacroStabilityInwardsExportRegistry();

            PersistableGeometryFactory.Create(soilProfile, idFactory, registry);

            // Call
            IEnumerable <PersistableState> states = PersistableStateFactory.Create(soilProfile, idFactory, registry);

            // Assert
            Assert.AreEqual(1, states.Count());

            PersistableState state = states.First();

            Assert.IsNotNull(state.Id);
            CollectionAssert.IsEmpty(state.StateLines);
            CollectionAssert.IsEmpty(state.StatePoints);
        }
コード例 #6
0
        /// <summary>
        /// Creates macro stability inwards input with an aquifer layer.
        /// </summary>
        /// <param name="thicknessAquiferLayer">The thickness of the aquifer layer.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsInput"/>.</returns>
        public static MacroStabilityInwardsInput CreateInputWithAquifer(double thicknessAquiferLayer = 1.0)
        {
            var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 0.0),
                new Point3D(1.0, 0, 0.0)
            });
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.0, new MacroStabilityInwardsSoilProfile1D(string.Empty, -thicknessAquiferLayer, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(0.0)
                {
                    Data =
                    {
                        IsAquifer = true
                    }
                }
            }));

            return(new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties())
            {
                SurfaceLine = surfaceLine,
                StochasticSoilProfile = stochasticSoilProfile
            });
        }
コード例 #7
0
        public void Update_ModelWithUpdatedStochasticSoilProfile_ProfileUpdated()
        {
            // Setup
            const string profileName                       = "A";
            var          soilProfile                       = new MacroStabilityInwardsSoilProfile1D(profileName, -2, CreateLayers1D());
            var          expectedUpdatedProfile            = new MacroStabilityInwardsStochasticSoilProfile(0.2, soilProfile);
            MacroStabilityInwardsStochasticSoilModel model = CreateValidModel(new[]
            {
                expectedUpdatedProfile
            });

            MacroStabilityInwardsStochasticSoilModel otherModel = CreateValidModel(new[]
            {
                new MacroStabilityInwardsStochasticSoilProfile(0.5, soilProfile)
            });

            // Call
            MacroStabilityInwardsStochasticSoilModelProfileDifference difference = model.Update(otherModel);

            // Assert
            CollectionAssert.IsEmpty(difference.AddedProfiles);
            CollectionAssert.AreEqual(new[]
            {
                expectedUpdatedProfile
            }, difference.UpdatedProfiles);
            CollectionAssert.IsEmpty(difference.RemovedProfiles);
        }
コード例 #8
0
        public void Update_ModelWithAddedProfile_ProfileAdded()
        {
            // Setup
            MacroStabilityInwardsStochasticSoilModel model = CreateValidModel(new[]
            {
                CreateStochasticSoilProfile()
            });

            var expectedAddedProfile = new MacroStabilityInwardsStochasticSoilProfile(0.2, new TestSoilProfile("Added Profile"));
            MacroStabilityInwardsStochasticSoilModel otherModel = CreateValidModel(new[]
            {
                CreateStochasticSoilProfile(),
                expectedAddedProfile
            });

            // Call
            MacroStabilityInwardsStochasticSoilModelProfileDifference difference = model.Update(otherModel);

            // Assert
            AssertStochasticSoilModelAreEqual(otherModel, model);

            CollectionAssert.AreEqual(new[]
            {
                expectedAddedProfile
            }, difference.AddedProfiles);
            CollectionAssert.IsEmpty(difference.UpdatedProfiles);
            CollectionAssert.IsEmpty(difference.RemovedProfiles);
        }
コード例 #9
0
        public void Update_ModelWithRemovedProfileSameNameOtherType_ProfileRemoved()
        {
            // Setup
            const string profileName            = "A";
            var          soilProfile            = new MacroStabilityInwardsSoilProfile1D(profileName, -2, CreateLayers1D());
            var          expectedRemovedProfile = new MacroStabilityInwardsStochasticSoilProfile(0.2, soilProfile);
            var          newProfile             = new MacroStabilityInwardsStochasticSoilProfile(
                0.2,
                new MacroStabilityInwardsSoilProfile2D(profileName, CreateLayers2D(), Enumerable.Empty <MacroStabilityInwardsPreconsolidationStress>()));
            MacroStabilityInwardsStochasticSoilModel model = CreateValidModel(new[]
            {
                expectedRemovedProfile
            });

            MacroStabilityInwardsStochasticSoilModel otherModel = CreateValidModel(new[]
            {
                newProfile
            });

            // Call
            MacroStabilityInwardsStochasticSoilModelProfileDifference difference = model.Update(otherModel);

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                newProfile
            }, difference.AddedProfiles);
            CollectionAssert.IsEmpty(difference.UpdatedProfiles);
            CollectionAssert.AreEqual(new[]
            {
                expectedRemovedProfile
            }, difference.RemovedProfiles);
        }
        public void Read_EntityWithStochasticSoilModel_ReturnCalculationScenarioWithInputObjectWithStochasticSoilModelPropertiesSet()
        {
            // Setup
            var random = new Random(21);
            MacroStabilityInwardsStochasticSoilModel stochasticSoilModel =
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel();
            var stochasticSoilModelEntity = new StochasticSoilModelEntity();

            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(random.NextDouble(),
                                                                                       MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D());
            var stochasticSoilProfileEntity = new MacroStabilityInwardsStochasticSoilProfileEntity
            {
                StochasticSoilModelEntity = stochasticSoilModelEntity
            };

            var collector = new ReadConversionCollector();

            collector.Read(stochasticSoilModelEntity, stochasticSoilModel);
            collector.Read(stochasticSoilProfileEntity, stochasticSoilProfile);

            MacroStabilityInwardsCalculationEntity entity = CreateValidCalculationEntity();

            entity.MacroStabilityInwardsStochasticSoilProfileEntity = stochasticSoilProfileEntity;

            // Call
            MacroStabilityInwardsCalculationScenario calculation = entity.Read(collector);

            // Assert
            MacroStabilityInwardsInput inputParameters = calculation.InputParameters;

            Assert.AreSame(stochasticSoilModel, inputParameters.StochasticSoilModel);
            Assert.AreSame(stochasticSoilProfile, inputParameters.StochasticSoilProfile);
        }
        private static TestCaseData[] StochasticProfileVariousCombinations()
        {
            var stochasticSoilProfile       = new MacroStabilityInwardsStochasticSoilProfile(1.0, CreateRandomProfile(22));
            var otherStochasticSoilProfileA = new MacroStabilityInwardsStochasticSoilProfile(0.5, CreateRandomProfile(22));
            var otherStochasticSoilProfileB = new MacroStabilityInwardsStochasticSoilProfile(1.0, CreateRandomProfile(23));

            const double    probability = 1.0;
            TestSoilProfile profile     = CreateRandomProfile(22);
            var             stochasticProfileSameProperties      = new MacroStabilityInwardsStochasticSoilProfile(probability, profile);
            var             otherStochasticProfileSameProperties = new MacroStabilityInwardsStochasticSoilProfile(probability, profile);

            return(new[]
            {
                new TestCaseData(stochasticSoilProfile, otherStochasticSoilProfileA)
                {
                    TestName = "Update_ProfileWithProfileADifferentProbability_UpdatesProperties"
                },
                new TestCaseData(stochasticSoilProfile, otherStochasticSoilProfileB)
                {
                    TestName = "Update_ProfileWithProfileBDifferentSoilProfile_UpdatesProperties"
                },
                new TestCaseData(stochasticProfileSameProperties, otherStochasticProfileSameProperties)
                {
                    TestName = "Update_ProfileWithProfileSameProperties_PropertiesRemainSame"
                }
            });
        }
        public void GetProperties_WithData_ReturnExpectedValues()
        {
            // Setup
            var soilProfile = new MacroStabilityInwardsSoilProfile1D("MacroStabilityInwardsSoilProfile", 0, new List <MacroStabilityInwardsSoilLayer1D>
            {
                new MacroStabilityInwardsSoilLayer1D(10)
            });
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(1.0, soilProfile);
            var stochasticSoilModel   = new MacroStabilityInwardsStochasticSoilModel("name", new[]
            {
                new Point2D(1.0, 2.0)
            }, new[]
            {
                stochasticSoilProfile
            });

            // Call
            var properties = new MacroStabilityInwardsStochasticSoilModelProperties(stochasticSoilModel);

            // Assert
            Assert.AreEqual(stochasticSoilModel.Name, properties.Name);
            CollectionAssert.AreEqual(stochasticSoilModel.Geometry, properties.Geometry);
            Assert.AreEqual(1, properties.MacroStabilityInwardsStochasticSoilProfiles.Length);
            Assert.AreSame(stochasticSoilProfile, properties.MacroStabilityInwardsStochasticSoilProfiles[0].Data);
        }
コード例 #13
0
        public void GivenViewWithWaternets_WhenWaternetSetEmpty_ThenNoChartData()
        {
            // Setup
            MacroStabilityInwardsStochasticSoilProfile originalSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D();

            var calculation = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    StochasticSoilProfile = originalSoilProfile,
                    SurfaceLine           = GetSurfaceLineWithGeometry()
                },
                Output = MacroStabilityInwardsOutputTestFactory.CreateOutput()
            };

            using (new MacroStabilityInwardsCalculatorFactoryConfig())
                using (var control = new MacroStabilityInwardsOutputChartControl(calculation,
                                                                                 new GeneralMacroStabilityInwardsInput(),
                                                                                 AssessmentSectionTestHelper.GetTestAssessmentLevel))
                {
                    // Precondition
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertInputChartData(calculation, GetChartControl(control).Data);

                    var calculatorFactory = (TestMacroStabilityInwardsCalculatorFactory)MacroStabilityInwardsCalculatorFactory.Instance;
                    calculatorFactory.LastCreatedWaternetDailyCalculator.Output   = WaternetCalculatorResultTestFactory.CreateEmptyResult();
                    calculatorFactory.LastCreatedWaternetExtremeCalculator.Output = WaternetCalculatorResultTestFactory.CreateEmptyResult();

                    // Call
                    control.UpdateChartData();

                    // Assert
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyWaternetChartData(GetChartControl(control).Data);
                }
        }
コード例 #14
0
        public void HasValidStatePoints_SoilProfileWithPOPAndPreconsolidationStressOnOneLayer_ReturnsFalse()
        {
            // Setup
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(new[]
            {
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, 1))
            });

            IMacroStabilityInwardsSoilLayer firstLayer = stochasticSoilProfile.SoilProfile.Layers.First();

            firstLayer.Data.UsePop = true;
            firstLayer.Data.Pop    = new VariationCoefficientLogNormalDistribution
            {
                Mean = (RoundedDouble)1,
                CoefficientOfVariation = (RoundedDouble)2
            };

            MacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfileUnderSurfaceLine = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(stochasticSoilProfile.SoilProfile,
                                                                                                                                                          CreateSurfaceLine());

            // Call
            bool hasValidStatePoints = PersistableStateHelper.HasValidStatePoints(soilProfileUnderSurfaceLine);

            // Assert
            Assert.IsFalse(hasValidStatePoints);
        }
コード例 #15
0
        public void Constructor_CalculationWithoutOutputAndWithWaternet_ChartDataEmpty()
        {
            // Setup
            MacroStabilityInwardsSurfaceLine           surfaceLine           = GetSurfaceLineWithGeometry();
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D();

            var calculation = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    SurfaceLine           = surfaceLine,
                    StochasticSoilProfile = stochasticSoilProfile
                }
            };

            // Call
            using (new MacroStabilityInwardsCalculatorFactoryConfig())
                using (var control = new MacroStabilityInwardsOutputChartControl(calculation,
                                                                                 new GeneralMacroStabilityInwardsInput(),
                                                                                 AssessmentSectionTestHelper.GetTestAssessmentLevel))
                {
                    // Assert
                    IChartControl       chartControl = GetChartControl(control);
                    ChartDataCollection chartData    = chartControl.Data;
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyChartDataWithEmptySoilLayerAndWithWaternetChartData(chartData);
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyOutputChartData(chartData);
                    Assert.AreEqual(calculation.Name, chartControl.ChartTitle);
                }
        }
コード例 #16
0
        public void GivenCalculationWithStochasticSoilProfileAndSurfaceLine_WhenStochasticSoilProfileUpdate_ThenChartDataUpdated()
        {
            // Given
            MacroStabilityInwardsStochasticSoilProfile originalSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D();

            var calculation = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    StochasticSoilProfile = originalSoilProfile,
                    SurfaceLine           = GetSurfaceLineWithGeometry()
                },
                Output = MacroStabilityInwardsOutputTestFactory.CreateOutput()
            };

            using (new MacroStabilityInwardsCalculatorFactoryConfig())
                using (var control = new MacroStabilityInwardsOutputChartControl(calculation,
                                                                                 new GeneralMacroStabilityInwardsInput(),
                                                                                 AssessmentSectionTestHelper.GetTestAssessmentLevel))
                {
                    ChartDataCollection chartData = GetChartControl(control).Data;

                    // Precondition
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertInputChartData(calculation, chartData);

                    MacroStabilityInwardsStochasticSoilProfile newSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D();

                    // When
                    calculation.InputParameters.StochasticSoilProfile = newSoilProfile;
                    control.UpdateChartData();

                    // Then
                    MacroStabilityInwardsOutputViewChartDataAssert.AssertInputChartData(calculation, chartData);
                }
        }
コード例 #17
0
        public void RemoveStochasticSoilProfileFromInput_NoCalculationsWithProfile_ReturnNoAffectedObjects()
        {
            // Setup
            MacroStabilityInwardsFailureMechanism failureMechanism = MacroStabilityInwardsTestDataGenerator.GetMacroStabilityInwardsFailureMechanismWithAllCalculationConfigurations();
            IEnumerable <MacroStabilityInwardsCalculationScenario> calculations = failureMechanism.Calculations
                                                                                  .Cast <MacroStabilityInwardsCalculationScenario>();
            MacroStabilityInwardsStochasticSoilProfile profileToDelete = null;

            foreach (MacroStabilityInwardsCalculationScenario calculationScenario in calculations)
            {
                MacroStabilityInwardsInput input = calculationScenario.InputParameters;
                MacroStabilityInwardsStochasticSoilProfile currentProfile = input.StochasticSoilProfile;
                if (profileToDelete == null)
                {
                    profileToDelete = currentProfile;
                }

                if (profileToDelete != null && ReferenceEquals(profileToDelete, currentProfile))
                {
                    input.StochasticSoilProfile = null;
                }
            }

            // Call
            IEnumerable <IObservable> affected = MacroStabilityInwardsDataSynchronizationService.RemoveStochasticSoilProfileFromInput(failureMechanism, profileToDelete);

            // Assert
            CollectionAssert.IsEmpty(affected);
        }
        /// <summary>
        /// Creates a <see cref="MacroStabilityInwardsStochasticSoilProfileEntity"/> based on
        /// the information of the <see cref="MacroStabilityInwardsStochasticSoilProfile"/>.
        /// </summary>
        /// <param name="stochasticSoilProfile">The stochastic soil profile to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsStochasticSoilProfileEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        /// <exception cref="NotSupportedException">Thrown when <see cref="MacroStabilityInwardsStochasticSoilProfile.SoilProfile"/> is
        /// not of type <see cref="MacroStabilityInwardsSoilProfile1D"/> or <see cref="MacroStabilityInwardsSoilProfile2D"/>.</exception>
        public static MacroStabilityInwardsStochasticSoilProfileEntity Create(this MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile,
                                                                              PersistenceRegistry registry,
                                                                              int order)
        {
            if (stochasticSoilProfile == null)
            {
                throw new ArgumentNullException(nameof(stochasticSoilProfile));
            }

            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (registry.Contains(stochasticSoilProfile))
            {
                return(registry.Get(stochasticSoilProfile));
            }

            var entity = new MacroStabilityInwardsStochasticSoilProfileEntity
            {
                Probability = stochasticSoilProfile.Probability,
                Order       = order
            };

            AddEntityForProfile(stochasticSoilProfile.SoilProfile, entity, registry);

            registry.Register(entity, stochasticSoilProfile);
            return(entity);
        }
コード例 #19
0
        public void Create_WithValidData_ReturnsPersistableStates()
        {
            // Setup
            MacroStabilityInwardsCalculationScenario   calculation           = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(new TestHydraulicBoundaryLocation());
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(new[]
            {
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, 1))
            });

            IMacroStabilityInwardsSoilLayer lastLayer = stochasticSoilProfile.SoilProfile.Layers.Last();

            lastLayer.Data.UsePop = true;
            lastLayer.Data.Pop    = new VariationCoefficientLogNormalDistribution
            {
                Mean = (RoundedDouble)1,
                CoefficientOfVariation = (RoundedDouble)2
            };
            calculation.InputParameters.StochasticSoilProfile = stochasticSoilProfile;

            IMacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfile = calculation.InputParameters.SoilProfileUnderSurfaceLine;

            var idFactory = new IdFactory();
            var registry  = new MacroStabilityInwardsExportRegistry();

            PersistableGeometryFactory.Create(soilProfile, idFactory, registry);

            // Call
            IEnumerable <PersistableState> states = PersistableStateFactory.Create(soilProfile, idFactory, registry);

            // Assert
            PersistableDataModelTestHelper.AssertStates(soilProfile, states);
            PersistableState state = states.First();

            Assert.AreEqual(registry.States[MacroStabilityInwardsExportStageType.Daily], state.Id);
        }
        public void Create_WithStochasticSoilProfiles_ReturnsStochasticSoilModelEntityWithPropertiesSet()
        {
            // Setup
            var stochasticSoilProfiles = new[]
            {
                new MacroStabilityInwardsStochasticSoilProfile(0.1, MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D()),
                new MacroStabilityInwardsStochasticSoilProfile(0.9, MacroStabilityInwardsSoilProfile2DTestFactory.CreateMacroStabilityInwardsSoilProfile2D())
            };
            MacroStabilityInwardsStochasticSoilModel stochasticSoilModel =
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("Model", stochasticSoilProfiles);

            var registry = new PersistenceRegistry();

            // Call
            StochasticSoilModelEntity entity = stochasticSoilModel.Create(registry, 0);

            // Assert
            Assert.IsNotNull(entity);
            CollectionAssert.IsEmpty(entity.PipingStochasticSoilProfileEntities);
            Assert.AreEqual(stochasticSoilProfiles.Length, entity.MacroStabilityInwardsStochasticSoilProfileEntities.Count);

            MacroStabilityInwardsStochasticSoilProfile       firstStochasticSoilProfile       = stochasticSoilProfiles[0];
            MacroStabilityInwardsStochasticSoilProfileEntity firstStochasticSoilProfileEntity = entity.MacroStabilityInwardsStochasticSoilProfileEntities.First();

            Assert.AreEqual(firstStochasticSoilProfile.Probability, firstStochasticSoilProfileEntity.Probability);
            Assert.IsNotNull(firstStochasticSoilProfileEntity.MacroStabilityInwardsSoilProfileOneDEntity);
            Assert.IsNull(firstStochasticSoilProfileEntity.MacroStabilityInwardsSoilProfileTwoDEntity);

            MacroStabilityInwardsStochasticSoilProfile       secondStochasticSoilProfile       = stochasticSoilProfiles[1];
            MacroStabilityInwardsStochasticSoilProfileEntity secondStochasticSoilProfileEntity = entity.MacroStabilityInwardsStochasticSoilProfileEntities.ElementAt(1);

            Assert.AreEqual(secondStochasticSoilProfile.Probability, secondStochasticSoilProfileEntity.Probability);
            Assert.IsNull(secondStochasticSoilProfileEntity.MacroStabilityInwardsSoilProfileOneDEntity);
            Assert.IsNotNull(secondStochasticSoilProfileEntity.MacroStabilityInwardsSoilProfileTwoDEntity);
        }
コード例 #21
0
        public void Clone_AllPropertiesSet_ReturnNewInstanceWithCopiedValues()
        {
            // Setup
            var surfaceLine = new MacroStabilityInwardsSurfaceLine("Surface line");

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0, 0),
                new Point3D(1, 1, 1)
            });

            MacroStabilityInwardsStochasticSoilModel   stochasticSoilModel   = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel();
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = stochasticSoilModel.StochasticSoilProfiles.First();

            // Precondition
            Assert.IsNotNull(stochasticSoilProfile);

            var original = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties());

            MacroStabilityInwardsTestDataGenerator.SetRandomMacroStabilityInwardsInput(original);

            // Call
            object clone = original.Clone();

            // Assert
            CoreCloneAssert.AreObjectClones(original, clone, MacroStabilityInwardsCloneAssert.AreClones);
        }
        public void Create_CalculationWithAlreadyRegisteredStochasticSoilProfile_ReturnsEntityWithStochasticSoilModelEntity()
        {
            // Setup
            var random = new Random(21);
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(random.NextDouble(),
                                                                                       MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D());
            var scenario = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    StochasticSoilProfile = stochasticSoilProfile
                }
            };

            var registry = new PersistenceRegistry();
            var stochasticSoilProfileEntity = new MacroStabilityInwardsStochasticSoilProfileEntity();

            registry.Register(stochasticSoilProfileEntity, stochasticSoilProfile);

            // Call
            MacroStabilityInwardsCalculationEntity entity = scenario.Create(registry, 0);

            // Assert
            Assert.IsNotNull(entity);
            MacroStabilityInwardsStochasticSoilProfileEntity expectedStochasticSoilProfileEntity = registry.Get(stochasticSoilProfile);

            Assert.AreSame(expectedStochasticSoilProfileEntity, entity.MacroStabilityInwardsStochasticSoilProfileEntity);
        }
コード例 #23
0
        public void ClearStochasticSoilProfileDependentData_NoCalculationsWithOutputWithProfile_ReturnInput()
        {
            // Setup
            MacroStabilityInwardsFailureMechanism failureMechanism = MacroStabilityInwardsTestDataGenerator.GetMacroStabilityInwardsFailureMechanismWithAllCalculationConfigurations();
            IEnumerable <MacroStabilityInwardsCalculationScenario> calculations = failureMechanism.Calculations
                                                                                  .Cast <MacroStabilityInwardsCalculationScenario>();
            MacroStabilityInwardsStochasticSoilProfile profileToDelete = null;

            var expectedInputs = new List <MacroStabilityInwardsInput>();

            foreach (MacroStabilityInwardsCalculationScenario calculationScenario in calculations)
            {
                MacroStabilityInwardsInput input = calculationScenario.InputParameters;
                MacroStabilityInwardsStochasticSoilProfile currentProfile = input.StochasticSoilProfile;
                if (profileToDelete == null)
                {
                    profileToDelete = currentProfile;
                }

                if (profileToDelete != null && ReferenceEquals(profileToDelete, currentProfile))
                {
                    calculationScenario.ClearOutput();
                    expectedInputs.Add(input);
                }
            }

            // Call
            IEnumerable <IObservable> affected = MacroStabilityInwardsDataSynchronizationService.ClearStochasticSoilProfileDependentData(failureMechanism, profileToDelete);

            // Assert
            CollectionAssert.AreEquivalent(expectedInputs, affected);
            CollectionAssert.IsEmpty(affected.Cast <MacroStabilityInwardsInput>().Where(a => a.StochasticSoilProfile == null));
        }
        public void ChildNodeObjects_Always_ReturnsChildrenOfData()
        {
            // Setup
            var stochasticSoilProfile1 = new MacroStabilityInwardsStochasticSoilProfile(
                1.0,
                new MacroStabilityInwardsSoilProfile1D("soilProfile1", 0, new List <MacroStabilityInwardsSoilLayer1D>
            {
                new MacroStabilityInwardsSoilLayer1D(10)
            }));
            var stochasticSoilProfile2 = new MacroStabilityInwardsStochasticSoilProfile(
                1.0,
                new MacroStabilityInwardsSoilProfile1D("soilProfile2", 0, new List <MacroStabilityInwardsSoilLayer1D>
            {
                new MacroStabilityInwardsSoilLayer1D(10)
            }));

            MacroStabilityInwardsStochasticSoilModel stochasticSoilModel =
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("SoilModel", new[]
            {
                stochasticSoilProfile1,
                stochasticSoilProfile2
            });

            // Call
            object[] objects = info.ChildNodeObjects(stochasticSoilModel);

            // Assert
            MacroStabilityInwardsStochasticSoilProfile[] expectedChildren =
            {
                stochasticSoilProfile1,
                stochasticSoilProfile2
            };
            CollectionAssert.AreEqual(expectedChildren, objects);
        }
コード例 #25
0
        public void VisibleProperties_WithSoilProfile1D_ExpectedAttributesValues()
        {
            // Setup
            var layer = new MacroStabilityInwardsSoilLayer1D(-2);
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.142, new MacroStabilityInwardsSoilProfile1D("<some name>", -5.0, new[]
            {
                layer
            }));

            // Call
            var properties = new MacroStabilityInwardsStochasticSoilProfileProperties(stochasticSoilProfile);

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(5, dynamicProperties.Count);

            PropertyDescriptor nameProperty = dynamicProperties[0];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty,
                                                                            generalCategoryName,
                                                                            "Naam",
                                                                            "De naam van de ondergrondschematisatie.",
                                                                            true);

            PropertyDescriptor contributionProperty = dynamicProperties[1];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(contributionProperty,
                                                                            generalCategoryName,
                                                                            "Aandeel [%]",
                                                                            "Het aandeel van de ondergrondschematisatie in het stochastische ondergrondmodel.",
                                                                            true);

            PropertyDescriptor layersProperty = dynamicProperties[2];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(layersProperty,
                                                                            generalCategoryName,
                                                                            "Grondlagen",
                                                                            "",
                                                                            true);

            PropertyDescriptor bottomProperty = dynamicProperties[3];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(bottomProperty,
                                                                            generalCategoryName,
                                                                            "Bodemniveau",
                                                                            "Het niveau van de onderkant van de ondergrondschematisatie.",
                                                                            true);

            PropertyDescriptor typeProperty = dynamicProperties[4];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(typeProperty,
                                                                            generalCategoryName,
                                                                            "Type",
                                                                            "Het type van de ondergrondschematisatie.",
                                                                            true);
        }
コード例 #26
0
        public void VisibleProperties_WithSoilProfile2D_ExpectedAttributesValues()
        {
            // Setup
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.142, new MacroStabilityInwardsSoilProfile2D("<some name>", new[]
            {
                CreateMacroStabilityInwardsSoilLayer2D()
            }, Enumerable.Empty <MacroStabilityInwardsPreconsolidationStress>()));

            // Call
            var properties = new MacroStabilityInwardsStochasticSoilProfileProperties(stochasticSoilProfile);

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(5, dynamicProperties.Count);

            PropertyDescriptor nameProperty = dynamicProperties[0];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty,
                                                                            generalCategoryName,
                                                                            "Naam",
                                                                            "De naam van de ondergrondschematisatie.",
                                                                            true);

            PropertyDescriptor contributionProperty = dynamicProperties[1];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(contributionProperty,
                                                                            generalCategoryName,
                                                                            "Aandeel [%]",
                                                                            "Het aandeel van de ondergrondschematisatie in het stochastische ondergrondmodel.",
                                                                            true);

            PropertyDescriptor layersProperty = dynamicProperties[2];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(layersProperty,
                                                                            generalCategoryName,
                                                                            "Grondlagen",
                                                                            "",
                                                                            true);

            PropertyDescriptor typeProperty = dynamicProperties[3];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(typeProperty,
                                                                            generalCategoryName,
                                                                            "Type",
                                                                            "Het type van de ondergrondschematisatie.",
                                                                            true);

            PropertyDescriptor preconsolidationProperty = dynamicProperties[4];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(preconsolidationProperty,
                                                                            generalCategoryName,
                                                                            "Grensspanningen",
                                                                            "De grensspanningen in de ondergrondschematisatie.",
                                                                            true);
        }
        public void Update_WithValidProfile_UpdatesProperties(MacroStabilityInwardsStochasticSoilProfile stochasticProfile,
                                                              MacroStabilityInwardsStochasticSoilProfile otherStochasticProfile)
        {
            // Call
            stochasticProfile.Update(otherStochasticProfile);

            // Assert
            Assert.AreEqual(otherStochasticProfile.Probability, stochasticProfile.Probability);
            Assert.AreSame(otherStochasticProfile.SoilProfile, stochasticProfile.SoilProfile);
        }
コード例 #28
0
        public void StochasticSoilProfile_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged()
        {
            // Setup
            MacroStabilityInwardsSoilProfile1D soilProfile = MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D();
            var newProfile = new MacroStabilityInwardsStochasticSoilProfile(0, soilProfile);
            var newValue   = new DataGridViewComboBoxItemWrapper <MacroStabilityInwardsStochasticSoilProfile>(newProfile);

            var calculation = new MacroStabilityInwardsCalculationScenario();

            // Call & Assert
            SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.StochasticSoilProfile = newValue, calculation);
        }
コード例 #29
0
        public void Update_WithOtherModel_PropertiesUpdated()
        {
            // Setup
            const string equalProfileName   = "nameA";
            var          stochasticProfileA = new MacroStabilityInwardsStochasticSoilProfile(0.5, CreateMacroStabilityInwardsSoilProfile(equalProfileName));
            var          stochasticProfileB = new MacroStabilityInwardsStochasticSoilProfile(0.5, CreateMacroStabilityInwardsSoilProfile("nameB"));
            MacroStabilityInwardsStochasticSoilModel model = CreateValidModel(new[]
            {
                stochasticProfileA,
                stochasticProfileB
            });

            const string otherName     = "other name";
            var          otherGeometry = new[]
            {
                new Point2D(2, 0),
                new Point2D(3, 0)
            };
            var otherStochasticProfileA = new MacroStabilityInwardsStochasticSoilProfile(0.7, new TestSoilProfile(equalProfileName));
            var otherStochasticProfileB = new MacroStabilityInwardsStochasticSoilProfile(0.3, CreateMacroStabilityInwardsSoilProfile("other profile name"));
            var otherModel = new MacroStabilityInwardsStochasticSoilModel(otherName, otherGeometry, new[]
            {
                otherStochasticProfileA,
                otherStochasticProfileB
            });

            // Call
            MacroStabilityInwardsStochasticSoilModelProfileDifference difference = model.Update(otherModel);

            // Assert
            AssertStochasticSoilModelAreEqual(otherModel, model);
            Assert.AreSame(otherGeometry, model.Geometry);

            MacroStabilityInwardsStochasticSoilProfile[] stochasticSoilProfiles = model.StochasticSoilProfiles.ToArray();
            Assert.AreEqual(2, stochasticSoilProfiles.Length);
            Assert.AreSame(stochasticProfileA, stochasticSoilProfiles[0]);
            Assert.AreSame(otherStochasticProfileA.SoilProfile, stochasticSoilProfiles[0].SoilProfile);
            Assert.AreNotSame(stochasticProfileB, stochasticSoilProfiles[1]);
            Assert.AreSame(otherStochasticProfileB.SoilProfile, stochasticSoilProfiles[1].SoilProfile);

            CollectionAssert.AreEqual(new[]
            {
                stochasticProfileA
            }, difference.UpdatedProfiles);
            CollectionAssert.AreEqual(new[]
            {
                stochasticProfileB
            }, difference.RemovedProfiles);
            CollectionAssert.AreEqual(new[]
            {
                otherStochasticProfileB
            }, difference.AddedProfiles);
        }
コード例 #30
0
        public void GetStochasticSoilModelsForSurfaceLine_SurfaceLineIntersectingSoilModel_ReturnSoilModel()
        {
            // Setup
            var soilProfile1 = new MacroStabilityInwardsStochasticSoilProfile(0.3, new MacroStabilityInwardsSoilProfile1D("Profile 1", -10.0, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(-5.0),
                new MacroStabilityInwardsSoilLayer1D(-2.0),
                new MacroStabilityInwardsSoilLayer1D(1.0)
            }));
            var soilProfile2 = new MacroStabilityInwardsStochasticSoilProfile(0.7, new MacroStabilityInwardsSoilProfile1D("Profile 2", -8.0, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(-4.0),
                new MacroStabilityInwardsSoilLayer1D(0.0),
                new MacroStabilityInwardsSoilLayer1D(4.0)
            }));

            var soilModel = new MacroStabilityInwardsStochasticSoilModel("A", new[]
            {
                new Point2D(1.0, 0.0),
                new Point2D(5.0, 0.0)
            }, new[]
            {
                soilProfile1,
                soilProfile2
            });

            MacroStabilityInwardsStochasticSoilModel[] availableSoilModels =
            {
                soilModel
            };

            var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(3.0, 5.0, 0.0),
                new Point3D(3.0, 0.0, 1.0),
                new Point3D(3.0, -5.0, 0.0)
            });

            // Call
            IEnumerable <MacroStabilityInwardsStochasticSoilModel> result = MacroStabilityInwardsCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine(
                surfaceLine,
                availableSoilModels);

            // Assert
            MacroStabilityInwardsStochasticSoilModel[] expected =
            {
                soilModel
            };
            CollectionAssert.AreEquivalent(expected, result);
        }