Exemplo n.º 1
0
        public void Create_ValidWaterPressureInterpolationModel_ExpectedWaterPressureInterpolationModel(
            WaterPressureInterpolationModel waterPressureInterpolationModel, CSharpWrapperWaterPressureInterpolationModel expectedWaterPressureInterpolationModel)
        {
            // Setup
            var profile = new SoilProfile(new[]
            {
                new SoilLayer(new Point2D[0],
                              new SoilLayer.ConstructionProperties
                {
                    WaterPressureInterpolationModel = waterPressureInterpolationModel
                },
                              Enumerable.Empty <SoilLayer>())
            }, Enumerable.Empty <PreconsolidationStress>());

            // Call
            LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(profile, out IDictionary <SoilLayer, LayerWithSoil> _);

            // Assert
            Assert.AreEqual(expectedWaterPressureInterpolationModel, layersWithSoil[0].WaterPressureInterpolationModel);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Converts a <see cref="Calculators.Input.WaterPressureInterpolationModel"/> into a <see cref="CSharpWrapperWaterPressureInterpolationModel"/>.
        /// </summary>
        /// <param name="waterPressureInterpolationModel">The <see cref="Calculators.Input.WaterPressureInterpolationModel"/> to convert.</param>
        /// <returns>A <see cref="CSharpWrapperWaterPressureInterpolationModel"/> based on <paramref name="waterPressureInterpolationModel"/>.</returns>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="waterPressureInterpolationModel"/>
        /// is an invalid value.</exception>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="waterPressureInterpolationModel"/>
        /// is a valid value, but unsupported.</exception>
        private static CSharpWrapperWaterPressureInterpolationModel ConvertWaterPressureInterpolationModel(WaterPressureInterpolationModel waterPressureInterpolationModel)
        {
            if (!Enum.IsDefined(typeof(WaterPressureInterpolationModel), waterPressureInterpolationModel))
            {
                throw new InvalidEnumArgumentException(nameof(waterPressureInterpolationModel),
                                                       (int)waterPressureInterpolationModel,
                                                       typeof(WaterPressureInterpolationModel));
            }

            switch (waterPressureInterpolationModel)
            {
            case WaterPressureInterpolationModel.Automatic:
                return(CSharpWrapperWaterPressureInterpolationModel.Automatic);

            case WaterPressureInterpolationModel.Hydrostatic:
                return(CSharpWrapperWaterPressureInterpolationModel.Hydrostatic);

            default:
                throw new NotSupportedException();
            }
        }