public void ConvertHugeCubicFeetsToCubicMeters() { Assert.AreEqual( 68356539.6476875, VolumeConverter.Convert(2413988640, VolumeUnit.CubicFeet, VolumeUnit.CubicMeters), Reservoir.Tolerance); }
public void ConvertTwoCubicMetersToUnknown() { Assert.AreEqual( 2, VolumeConverter.Convert(2, VolumeUnit.CubicMeters, VolumeUnit.Unknown), Reservoir.Tolerance); }
public void ConvertTwoUnknownToCubicFeets() { Assert.AreEqual( 2, VolumeConverter.Convert(2, VolumeUnit.Unknown, VolumeUnit.CubicFeet), Reservoir.Tolerance); }
public void ConvertOneCubicMeterToCubicFeet() { Assert.AreEqual( CubicCubicFeetToCubicMeeterRelation, VolumeConverter.Convert(1, VolumeUnit.CubicMeters, VolumeUnit.CubicFeet), Reservoir.Tolerance); }
/// <summary> /// Calculates the original gravity of a sud based on the provided malts and adjuncts /// Formula : http://www.brewersfriend.com /// </summary> /// <returns></returns> private void calculateGravity() { float gravity = 0.0f; float maltGravity = 0.0f; float adjunctGravity = 0.0f;//not affeted by boilding efficiency (usually added later) foreach (Malt item in ItemList) { if (item.isMashable) { maltGravity += item.PPG * WeightConverter.Convert(item.Amount, "Pound"); } else { adjunctGravity += item.PPG * WeightConverter.Convert(item.Amount, "Pound"); } } maltGravity *= (this._Efficiency / 100); gravity = maltGravity + adjunctGravity; gravity /= VolumeConverter.Convert(this._BatchVolume, "US Gallon"); //output range 1.000 - 1.1XX Gravity = (float)(gravity * 0.001 + 1); }
public void Convert() { double result = VolumeConverter.Convert( VolumeUnit.Gallon, VolumeUnit.Quart, 1); Assert.AreEqual(4, result); }
public void ConvertHugeCubicFeetsToBarrels() { Assert.AreEqual( 429955516.6704, VolumeConverter.Convert(2413988640, VolumeUnit.CubicFeet, VolumeUnit.Barrels), Reservoir.Tolerance); }
public void Test20GallonConvertsToMillilitres() { // Arrange var converter = new VolumeConverter(); var inputvalue = 20; // Act var result = converter.Convert(inputvalue, Volume.Gallon, Volume.Millilitre); // Assert Assert.AreEqual(75708.2, result, 0.1); }
public void Test1GallonConvertsTo3Point7Litres() { // Arrange var converter = new VolumeConverter(); var inputvalue = 1; // Act var result = converter.Convert(inputvalue, Volume.Gallon, Volume.Liter); // Assert Assert.AreEqual(3.78541, result, 0.1); }
public void Test10000MililiterConvertsTo2point6Gallon() { // Arrange var converter = new VolumeConverter(); var inputvalue = 10000; // Act var result = converter.Convert(inputvalue, Volume.Millilitre, Volume.Gallon); // Assert Assert.AreEqual(2.641721, result, 0.1); }
public void Test5LitreConvertsTo5000Millilitre() { // Arrange var converter = new VolumeConverter(); var inputvalue = 5; // Act var result = converter.Convert(inputvalue, Volume.Liter, Volume.Millilitre); // Assert Assert.AreEqual(5000, result); }
public void Test1000MililiterConvertsTo1Liter() { // Arrange var converter = new VolumeConverter(); var inputvalue = 1000; // Act var result = converter.Convert(inputvalue, Volume.Millilitre, Volume.Liter); // Assert Assert.AreEqual(1, result); }
public void Test5LitreConvertsTo1point3Gallon() { // Arrange var converter = new VolumeConverter(); var inputvalue = 5; // Act var result = converter.Convert(inputvalue, Volume.Liter, Volume.Gallon); // Assert Assert.AreEqual(1.32086, result, 0.1); }
/// <summary>Convert the numbers to the new unit.</summary> /// <param name="numbers">The numbers used in the convertion.</param> /// <returns>The result of the convertion execution.</returns> /// <exception cref="ArgumentNullException">When numbers is null.</exception> /// <exception cref="ArgumentException">When the length of numbers do not equal <see cref="ArgumentCount"/>.</exception> public double Convert(double[] numbers) { base.Validate(numbers); double fromValue = numbers[0]; switch (current.UnitType) { case UnitType.Length: return(LengthConverter.Convert( (LengthUnit)current.FromUnit, (LengthUnit)current.ToUnit, fromValue)); case UnitType.Mass: return(MassConverter.Convert( (MassUnit)current.FromUnit, (MassUnit)current.ToUnit, fromValue)); case UnitType.Speed: return(SpeedConverter.Convert( (SpeedUnit)current.FromUnit, (SpeedUnit)current.ToUnit, fromValue)); case UnitType.Temperature: return(TemperatureConverter.Convert( (TemperatureUnit)current.FromUnit, (TemperatureUnit)current.ToUnit, fromValue)); case UnitType.Time: return(TimeConverter.Convert( (TimeUnit)current.FromUnit, (TimeUnit)current.ToUnit, fromValue)); case UnitType.Volume: return(VolumeConverter.Convert( (VolumeUnit)current.FromUnit, (VolumeUnit)current.ToUnit, fromValue)); default: throw new ArgumentOutOfRangeException("numbers"); } }
public ActionResult ConvertVolume(float?inputvolume, Volume inputunit, Volume outputunit) { if (ModelState.IsValid && inputvolume.HasValue) { var converter = new VolumeConverter(); var result = converter.Convert(inputvolume.Value, inputunit, outputunit); var con = new UnitConverter.Dto.Convert(); con.outputvolume = result; return(View("Index", con)); } else { return(View("Index")); } }
/// <summary>Convert the numbers to the new unit.</summary> /// <param name="numbers">The numbers used in the conversion.</param> /// <returns>The result of the conversion execution.</returns> /// <exception cref="ArgumentNullException">When numbers is null.</exception> /// <exception cref="ArgumentException">When the length of numbers do not equal <see cref="ArgumentCount"/>.</exception> public PreciseNumber Evaluate(PreciseNumber[] operands) { ((IExpression)this).Validate(operands); PreciseNumber fromValue = operands[0]; if (!fromValue.HasValue) { return(fromValue); } return(_current.UnitType switch { UnitType.Length => new PreciseNumber(LengthConverter.Convert((LengthUnit)_current.FromUnit, (LengthUnit)_current.ToUnit, fromValue.Value)), UnitType.Mass => new PreciseNumber(MassConverter.Convert((MassUnit)_current.FromUnit, (MassUnit)_current.ToUnit, fromValue.Value)), UnitType.Speed => new PreciseNumber(SpeedConverter.Convert((SpeedUnit)_current.FromUnit, (SpeedUnit)_current.ToUnit, fromValue.Value)), UnitType.Temperature => new PreciseNumber(TemperatureConverter.Convert((TemperatureUnit)_current.FromUnit, (TemperatureUnit)_current.ToUnit, fromValue.Value)), UnitType.Time => new PreciseNumber(TimeConverter.Convert((TimeUnit)_current.FromUnit, (TimeUnit)_current.ToUnit, fromValue.Value)), UnitType.Volume => new PreciseNumber(VolumeConverter.Convert((VolumeUnit)_current.FromUnit, (VolumeUnit)_current.ToUnit, fromValue.Value)), _ => throw new ArgumentOutOfRangeException(nameof(operands)), });
public void ConvertToSame() { var value = conv.Convert(0.032, VolumeUnits.CubicMeters, VolumeUnits.CubicMeters); Assert.Equal(0.032, value, 4); }
public void VolumeConverter_Convert() { decimal result = VolumeConverter.Convert(VolumeUnit.Gallon, VolumeUnit.Quart, 1); Assert.AreEqual(4, result); }
public void ConvertOneCubicFeetToCubicMeter() { Assert.AreEqual( 1 / CubicCubicFeetToCubicMeeterRelation, VolumeConverter.Convert(1, VolumeUnit.CubicFeet, VolumeUnit.CubicMeters)); }
public void ConvertZeroCubicFeetToCubicMeter() { Assert.AreEqual( 0, VolumeConverter.Convert(0, VolumeUnit.CubicFeet, VolumeUnit.CubicMeters)); }
private void Convert(double value) { switch (SelectedOp) { case "Length": { LengthunitConverter unit = new LengthunitConverter(); Result = unit.Convert(value, SelectedFrom, SelectedTo).ToString(); break; } case "Mass and Weight": { MassConverter unit = new MassConverter(); Result = unit.Convert(value, SelectedFrom, SelectedTo).ToString(); break; } case "Power": { PowerConverter unit = new PowerConverter(); Result = unit.Convert(value, SelectedFrom, SelectedTo).ToString(); break; } case "Pressure": { PressureConverter unit = new PressureConverter(); Result = unit.Convert(value, SelectedFrom, SelectedTo).ToString(); break; } case "Energy": { EnergyConveter unit = new EnergyConveter(); Result = unit.Convert(value, SelectedFrom, SelectedTo).ToString(); break; } case "Temperature": { TemperatureConverter unit = new TemperatureConverter(); Result = unit.Convert(value, SelectedFrom, SelectedTo).ToString(); break; } case "Volume": { VolumeConverter unit = new VolumeConverter(); Result = unit.Convert(value, SelectedFrom, SelectedTo).ToString(); break; } case "Angle": { AngleConverter unit = new AngleConverter(); Result = unit.Convert(value, SelectedFrom, SelectedTo).ToString(); break; } case "Area": { AreaConverter unit = new AreaConverter(); Result = unit.Convert(value, SelectedFrom, SelectedTo).ToString(); break; } case "Speed": { SpeedConverter unit = new SpeedConverter(); Result = unit.Convert(value, SelectedFrom, SelectedTo).ToString(); break; } case "Time": { TimeunitsConverter unit = new TimeunitsConverter(); Result = unit.Convert(value, SelectedFrom, SelectedTo).ToString(); break; } } }