public void CanConvertLiterToMeterCubed() { const decimal liters = 1000m; const decimal expectedCubicMeters = liters / 1000m; var cubicMeters = MeterConverter.ToMetersFrom(liters, Volume.Liter); Assert.Equal(expectedCubicMeters, cubicMeters); }
public void CanConverterMeterCubedToLiter() { const decimal cubicMeters = 1m; const decimal expectedLiters = cubicMeters * 1000m; var liters = MeterConverter.FromMetersTo(cubicMeters, Volume.Liter); Assert.Equal(expectedLiters, liters); }
/// <summary> /// Multiplies the constant density of water and gravity of earth by the radius of the /// pool to find the total internal pressure, measured in Pascals. /// </summary> /// <param name="radius"></param> /// <returns></returns> private static decimal GetInternalPressure(Length radius) { var waterDensity = new WaterDensity(); var gravity = new Gravity(); var radiusInMeters = MeterConverter.ToMetersFrom(radius.Value, radius.UnitOfMeasure); var result = waterDensity.Value * gravity.Value * radiusInMeters; return(result); }
/// <summary> /// Handles the calculation. /// </summary> /// <param name="wallMaterial">The material that the wall is made out of.</param> /// <param name="radius">The radius of the pool.</param> /// <param name="outputUnitOfMeasure">The unit of measure that the output value should be formatted in.</param> /// <returns></returns> public static decimal CalculateMaximumWaterDepth(IWallMaterial wallMaterial, Length radius, Quantities.Length outputUnitOfMeasure = Quantities.Length.Meter) { var maximumInternalPressureWallCanWithstand = GetMaximumInternalPressureWallCanWithstand(wallMaterial); var internalPressure = GetInternalPressure(radius); var maximumWaterDepthInMeters = maximumInternalPressureWallCanWithstand / internalPressure; var convertedMaximumWaterDepth = MeterConverter.FromMetersTo(maximumWaterDepthInMeters, outputUnitOfMeasure); return(convertedMaximumWaterDepth); }
/// <summary> /// Multiplies the wall's thickness by its tensile strength to find the maximum /// internal pressure that it can withstand, measured in Kilograms per second square. /// </summary> /// <param name="wallMaterial">The material that the wall is made of.</param> /// <returns></returns> private static decimal GetMaximumInternalPressureWallCanWithstand(IWallMaterial wallMaterial) { var wallMaterialThicknessInMeters = MeterConverter.ToMetersFrom( wallMaterial.Thickness.Value, wallMaterial.Thickness.UnitOfMeasure ); var wallMaterialTensileStrengthInPascals = PascalConverter.ToPascalFrom( wallMaterial.TensileStrength.Value, wallMaterial.TensileStrength.UnitOfMeasure ); var result = wallMaterialThicknessInMeters * wallMaterialTensileStrengthInPascals; return(result); }
/// <summary> /// Constructs a new Water Density. The value will change based on the unit of measure selected. /// </summary> /// <param name="unitOfMeasure"></param> public WaterDensity(Density unitOfMeasure = Density.KilogramPerMeterCubed) { UnitOfMeasure = unitOfMeasure; switch (unitOfMeasure) { case Density.KilogramPerLiter: Value = MeterConverter.FromMetersTo( DensityOfWaterInKilogramsPerMeterCubedAtStandardTemperatureAndPressure, Volume.Liter ); break; case Density.KilogramPerMeterCubed: Value = DensityOfWaterInKilogramsPerMeterCubedAtStandardTemperatureAndPressure; break; default: throw new System.NotSupportedException("Density type of: " + unitOfMeasure + " is currently not supported."); } }