private static void SetInputParametersToEntity(SemiProbabilisticPipingCalculationEntity entity, SemiProbabilisticPipingInput inputParameters, PersistenceRegistry registry) { if (inputParameters.SurfaceLine != null) { entity.SurfaceLineEntity = registry.Get(inputParameters.SurfaceLine); } SetHydraulicBoundaryLocationInputToEntity(entity, inputParameters, registry); if (inputParameters.StochasticSoilProfile != null) { entity.PipingStochasticSoilProfileEntity = registry.Get(inputParameters.StochasticSoilProfile); } entity.ExitPointL = inputParameters.ExitPointL.Value.ToNaNAsNull(); entity.EntryPointL = inputParameters.EntryPointL.Value.ToNaNAsNull(); entity.PhreaticLevelExitMean = inputParameters.PhreaticLevelExit.Mean.ToNaNAsNull(); entity.PhreaticLevelExitStandardDeviation = inputParameters.PhreaticLevelExit.StandardDeviation.ToNaNAsNull(); entity.DampingFactorExitMean = inputParameters.DampingFactorExit.Mean.ToNaNAsNull(); entity.DampingFactorExitStandardDeviation = inputParameters.DampingFactorExit.StandardDeviation.ToNaNAsNull(); }
private static void ReadInputParameters(SemiProbabilisticPipingInput inputParameters, SemiProbabilisticPipingCalculationEntity entity, ReadConversionCollector collector) { if (entity.SurfaceLineEntity != null) { inputParameters.SurfaceLine = entity.SurfaceLineEntity.ReadAsPipingSurfaceLine(collector); } inputParameters.UseAssessmentLevelManualInput = Convert.ToBoolean(entity.UseAssessmentLevelManualInput); inputParameters.AssessmentLevel = (RoundedDouble)entity.AssessmentLevel.ToNullAsNaN(); if (entity.HydraulicLocationEntity != null) { inputParameters.HydraulicBoundaryLocation = entity.HydraulicLocationEntity.Read(collector); } if (entity.PipingStochasticSoilProfileEntity != null) { inputParameters.StochasticSoilModel = entity.PipingStochasticSoilProfileEntity.StochasticSoilModelEntity.ReadAsPipingStochasticSoilModel(collector); inputParameters.StochasticSoilProfile = entity.PipingStochasticSoilProfileEntity.Read(collector); } inputParameters.EntryPointL = (RoundedDouble)entity.EntryPointL.ToNullAsNaN(); inputParameters.ExitPointL = (RoundedDouble)entity.ExitPointL.ToNullAsNaN(); inputParameters.PhreaticLevelExit.Mean = (RoundedDouble)entity.PhreaticLevelExitMean.ToNullAsNaN(); inputParameters.PhreaticLevelExit.StandardDeviation = (RoundedDouble)entity.PhreaticLevelExitStandardDeviation.ToNullAsNaN(); inputParameters.DampingFactorExit.Mean = (RoundedDouble)entity.DampingFactorExitMean.ToNullAsNaN(); inputParameters.DampingFactorExit.StandardDeviation = (RoundedDouble)entity.DampingFactorExitStandardDeviation.ToNullAsNaN(); }
public void ParameteredConstructor_CalculationNull_ThrowsArgumentNullException() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var calculationInput = new SemiProbabilisticPipingInput(); var surfaceLines = new[] { new PipingSurfaceLine(string.Empty) }; PipingStochasticSoilModel[] stochasticSoilModels = { PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel() }; var failureMechanism = new PipingFailureMechanism(); // Call TestDelegate call = () => new SemiProbabilisticPipingInputContext(calculationInput, null, surfaceLines, stochasticSoilModels, failureMechanism, assessmentSection); // Assert var exception = Assert.Throws <ArgumentNullException>(call); Assert.AreEqual("calculation", exception.ParamName); mocks.VerifyAll(); }
/// <summary> /// This method sets random data values to all properties of <paramref name="input"/>. /// </summary> /// <param name="input">The input to set the random data values to.</param> public static void SetRandomDataToPipingInput(SemiProbabilisticPipingInput input) { SetRandomDataToPipingInput((PipingInput)input); var random = new Random(21); input.UseAssessmentLevelManualInput = random.NextBoolean(); input.AssessmentLevel = random.NextRoundedDouble(); }
public void Constructor_ExpectedValues() { // Call var inputParameters = new SemiProbabilisticPipingInput(); // Assert Assert.IsInstanceOf <PipingInput>(inputParameters); Assert.IsNaN(inputParameters.AssessmentLevel); Assert.AreEqual(2, inputParameters.AssessmentLevel.NumberOfDecimalPlaces); Assert.IsFalse(inputParameters.UseAssessmentLevelManualInput); }
private static void SetHydraulicBoundaryLocationInputToEntity(SemiProbabilisticPipingCalculationEntity entity, SemiProbabilisticPipingInput inputParameters, PersistenceRegistry registry) { entity.UseAssessmentLevelManualInput = Convert.ToByte(inputParameters.UseAssessmentLevelManualInput); entity.AssessmentLevel = inputParameters.AssessmentLevel.ToNaNAsNull(); if (inputParameters.HydraulicBoundaryLocation != null) { entity.HydraulicLocationEntity = registry.Get(inputParameters.HydraulicBoundaryLocation); } }
private static void ToSemiProbabilisticConfiguration(PipingCalculationConfiguration calculationConfiguration, SemiProbabilisticPipingInput input) { if (input.UseAssessmentLevelManualInput) { calculationConfiguration.AssessmentLevel = input.AssessmentLevel; } else if (input.HydraulicBoundaryLocation != null) { calculationConfiguration.HydraulicBoundaryLocationName = input.HydraulicBoundaryLocation.Name; } }
public void Clone_AllPropertiesSet_ReturnNewInstanceWithCopiedValues() { // Setup var original = new SemiProbabilisticPipingInput(); PipingTestDataGenerator.SetRandomDataToPipingInput(original); // Call object clone = original.Clone(); // Assert CoreCloneAssert.AreObjectClones(original, clone, PipingCloneAssert.AreClones); }
private static List <string> ValidateInput(SemiProbabilisticPipingInput input, GeneralPipingInput generalInput, RoundedDouble normativeAssessmentLevel) { var validationResults = new List <string>(); validationResults.AddRange(ValidateHydraulics(input, normativeAssessmentLevel)); validationResults.AddRange(PipingCalculationValidationHelper.GetValidationErrors(input)); if (!validationResults.Any()) { validationResults.AddRange(ValidateCoverageLayers(input, generalInput)); } return(validationResults); }
public void AssessmentLevel_SetToNew_ValueIsRounded() { // Setup const double assessmentLevel = 1.111111; var input = new SemiProbabilisticPipingInput(); int originalNumberOfDecimalPlaces = input.AssessmentLevel.NumberOfDecimalPlaces; // Call input.AssessmentLevel = (RoundedDouble)assessmentLevel; // Assert Assert.AreEqual(originalNumberOfDecimalPlaces, input.AssessmentLevel.NumberOfDecimalPlaces); Assert.AreEqual(assessmentLevel, input.AssessmentLevel, input.AssessmentLevel.GetAccuracy()); }
private static IEnumerable <string> ValidateAssessmentLevel(SemiProbabilisticPipingInput input, RoundedDouble normativeAssessmentLevel) { var validationResult = new List <string>(); if (input.UseAssessmentLevelManualInput) { validationResult.AddRange(new NumericInputRule(input.AssessmentLevel, ParameterNameExtractor.GetFromDisplayName(RiskeerCommonFormsResources.WaterLevel_DisplayName)).Validate()); } else { if (double.IsNaN(normativeAssessmentLevel)) { validationResult.Add(RiskeerCommonServiceResources.CalculationService_ValidateInput_Cannot_determine_AssessmentLevel); } } return(validationResult); }
protected override void AssertPipingCalculationScenario(SemiProbabilisticPipingCalculationScenario expectedCalculation, SemiProbabilisticPipingCalculationScenario actualCalculation) { AssertPipingCalculationScenarioGenericProperties(expectedCalculation, actualCalculation); SemiProbabilisticPipingInput expectedInput = expectedCalculation.InputParameters; SemiProbabilisticPipingInput actualInput = actualCalculation.InputParameters; Assert.AreEqual(expectedInput.UseAssessmentLevelManualInput, actualInput.UseAssessmentLevelManualInput); if (expectedInput.UseAssessmentLevelManualInput) { Assert.AreEqual(expectedInput.AssessmentLevel, actualInput.AssessmentLevel); } else { Assert.AreSame(expectedInput.HydraulicBoundaryLocation, actualInput.HydraulicBoundaryLocation); } }
public void Clone_NotAllPropertiesSet_ReturnNewInstanceWithCopiedValues() { // Setup var original = new SemiProbabilisticPipingInput(); PipingTestDataGenerator.SetRandomDataToPipingInput(original); original.SurfaceLine = null; original.StochasticSoilModel = null; original.StochasticSoilProfile = null; original.HydraulicBoundaryLocation = null; // Call object clone = original.Clone(); // Assert CoreCloneAssert.AreObjectClones(original, clone, PipingCloneAssert.AreClones); }
private static IEnumerable <string> ValidateHydraulics(SemiProbabilisticPipingInput input, RoundedDouble normativeAssessmentLevel) { var validationResults = new List <string>(); if (!input.UseAssessmentLevelManualInput && input.HydraulicBoundaryLocation == null) { validationResults.Add(RiskeerCommonServiceResources.CalculationService_ValidateInput_No_hydraulic_boundary_location_selected); } else { validationResults.AddRange(ValidateAssessmentLevel(input, normativeAssessmentLevel)); RoundedDouble piezometricHeadExit = DerivedSemiProbabilisticPipingInput.GetPiezometricHeadExit(input, GetEffectiveAssessmentLevel(input, normativeAssessmentLevel)); if (double.IsNaN(piezometricHeadExit) || double.IsInfinity(piezometricHeadExit)) { validationResults.Add(Resources.SemiProbabilisticPipingCalculationService_ValidateInput_Cannot_determine_PiezometricHeadExit); } } return(validationResults); }
public void GetViewData_WithContext_ReturnsWrappedCalculation() { // Setup var assessmentSection = mocks.Stub <IAssessmentSection>(); mocks.ReplayAll(); var pipingInput = new SemiProbabilisticPipingInput(); var calculation = new SemiProbabilisticPipingCalculationScenario(); var calculationInputContext = new SemiProbabilisticPipingInputContext(pipingInput, calculation, Enumerable.Empty <PipingSurfaceLine>(), Enumerable.Empty <PipingStochasticSoilModel>(), new PipingFailureMechanism(), assessmentSection); // Call object viewData = info.GetViewData(calculationInputContext); // Assert Assert.AreSame(calculation, viewData); mocks.VerifyAll(); }
private static PipingCalculatorInput CreateInputFromData(SemiProbabilisticPipingInput input, GeneralPipingInput generalPipingInput, RoundedDouble normativeAssessmentLevel) { RoundedDouble effectiveAssessmentLevel = GetEffectiveAssessmentLevel(input, normativeAssessmentLevel); return(new PipingCalculatorInput( new PipingCalculatorInput.ConstructionProperties { WaterVolumetricWeight = generalPipingInput.WaterVolumetricWeight, SaturatedVolumicWeightOfCoverageLayer = SemiProbabilisticPipingDesignVariableFactory.GetSaturatedVolumicWeightOfCoverageLayer(input).GetDesignValue(), UpliftModelFactor = SemiProbabilisticPipingDesignVariableFactory.GetUpliftModelFactorDesignVariable(generalPipingInput).GetDesignValue(), AssessmentLevel = effectiveAssessmentLevel, PiezometricHeadExit = DerivedSemiProbabilisticPipingInput.GetPiezometricHeadExit(input, effectiveAssessmentLevel), DampingFactorExit = SemiProbabilisticPipingDesignVariableFactory.GetDampingFactorExit(input).GetDesignValue(), PhreaticLevelExit = PipingDesignVariableFactory.GetPhreaticLevelExit(input).GetDesignValue(), CriticalHeaveGradient = SemiProbabilisticPipingDesignVariableFactory.GetCriticalHeaveGradientDesignVariable(generalPipingInput).GetDesignValue(), ThicknessCoverageLayer = SemiProbabilisticPipingDesignVariableFactory.GetThicknessCoverageLayer(input).GetDesignValue(), EffectiveThicknessCoverageLayer = SemiProbabilisticPipingDesignVariableFactory.GetEffectiveThicknessCoverageLayer(input, generalPipingInput).GetDesignValue(), SellmeijerModelFactor = SemiProbabilisticPipingDesignVariableFactory.GetSellmeijerModelFactorDesignVariable(generalPipingInput).GetDesignValue(), SellmeijerReductionFactor = generalPipingInput.SellmeijerReductionFactor, SeepageLength = SemiProbabilisticPipingDesignVariableFactory.GetSeepageLength(input).GetDesignValue(), SandParticlesVolumicWeight = generalPipingInput.SandParticlesVolumicWeight, WhitesDragCoefficient = generalPipingInput.WhitesDragCoefficient, Diameter70 = SemiProbabilisticPipingDesignVariableFactory.GetDiameter70(input).GetDesignValue(), DarcyPermeability = SemiProbabilisticPipingDesignVariableFactory.GetDarcyPermeability(input).GetDesignValue(), WaterKinematicViscosity = generalPipingInput.WaterKinematicViscosity, Gravity = generalPipingInput.Gravity, ThicknessAquiferLayer = SemiProbabilisticPipingDesignVariableFactory.GetThicknessAquiferLayer(input).GetDesignValue(), MeanDiameter70 = generalPipingInput.MeanDiameter70, BeddingAngle = generalPipingInput.BeddingAngle, ExitPointXCoordinate = input.ExitPointL, SurfaceLine = input.SurfaceLine, SoilProfile = input.StochasticSoilProfile?.SoilProfile })); }
private static RoundedDouble GetEffectiveAssessmentLevel(SemiProbabilisticPipingInput input, RoundedDouble normativeAssessmentLevel) { return(input.UseAssessmentLevelManualInput ? input.AssessmentLevel : normativeAssessmentLevel); }
public void Create_SemiProbabilisticPipingCalculationScenarioWithPropertiesSet_ReturnSemiProbabilisticPipingCalculationEntity( bool isRelevant, bool useAssessmentLevelManualInput, double contribution, string name, string comments, double exitPoint, double entryPoint, double assessmentLevel, int order, int randomSeed) { // Setup var random = new Random(randomSeed); var calculation = new SemiProbabilisticPipingCalculationScenario { IsRelevant = isRelevant, Contribution = (RoundedDouble)contribution, Name = name, Comments = { Body = comments }, InputParameters = { ExitPointL = (RoundedDouble)exitPoint, EntryPointL = (RoundedDouble)entryPoint, PhreaticLevelExit = { Mean = random.NextRoundedDouble(-9999.9999, 9999.9999), StandardDeviation = random.NextRoundedDouble(1e-6, 9999.9999) }, DampingFactorExit = { Mean = random.NextRoundedDouble(1e-6, 9999.9999), StandardDeviation = random.NextRoundedDouble(1e-6, 9999.9999) }, UseAssessmentLevelManualInput = useAssessmentLevelManualInput, AssessmentLevel = (RoundedDouble)assessmentLevel } }; var registry = new PersistenceRegistry(); // Call SemiProbabilisticPipingCalculationEntity entity = calculation.Create(registry, order); // Assert Assert.AreEqual(Convert.ToByte(isRelevant), entity.RelevantForScenario); Assert.AreEqual(calculation.Contribution, entity.ScenarioContribution); Assert.AreEqual(name, entity.Name); Assert.AreEqual(comments, entity.Comments); Assert.AreEqual(exitPoint.ToNaNAsNull(), entity.ExitPointL); Assert.AreEqual(entryPoint.ToNaNAsNull(), entity.EntryPointL); SemiProbabilisticPipingInput input = calculation.InputParameters; Assert.AreEqual(input.PhreaticLevelExit.Mean.Value, entity.PhreaticLevelExitMean); Assert.AreEqual(input.PhreaticLevelExit.StandardDeviation.Value, entity.PhreaticLevelExitStandardDeviation); Assert.AreEqual(input.DampingFactorExit.Mean.Value, entity.DampingFactorExitMean); Assert.AreEqual(input.DampingFactorExit.StandardDeviation.Value, entity.DampingFactorExitStandardDeviation); Assert.AreEqual(Convert.ToByte(input.UseAssessmentLevelManualInput), entity.UseAssessmentLevelManualInput); Assert.AreEqual(input.AssessmentLevel.ToNaNAsNull(), entity.AssessmentLevel); Assert.AreEqual(order, entity.Order); Assert.AreEqual(0, entity.SemiProbabilisticPipingCalculationEntityId); Assert.IsNull(entity.CalculationGroupEntity); Assert.IsNull(entity.SurfaceLineEntity); Assert.IsNull(entity.PipingStochasticSoilProfileEntity); Assert.IsNull(entity.HydraulicLocationEntity); CollectionAssert.IsEmpty(entity.SemiProbabilisticPipingCalculationOutputEntities); }
/// <summary> /// Method that asserts whether <paramref name="original"/> and <paramref name="clone"/> /// are clones. /// </summary> /// <param name="original">The original object.</param> /// <param name="clone">The cloned object.</param> /// <exception cref="AssertionException">Thrown when <paramref name="original"/> and /// <paramref name="clone"/> are not clones.</exception> public static void AreClones(SemiProbabilisticPipingInput original, SemiProbabilisticPipingInput clone) { AreClones((PipingInput)original, clone); Assert.AreEqual(original.AssessmentLevel, clone.AssessmentLevel); Assert.AreEqual(original.UseAssessmentLevelManualInput, clone.UseAssessmentLevelManualInput); }