-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the UnitRelations.json (#1453)
As per my comments from #1200 here are the proposed modifications to the operators: - [x] adding an `Inverse` relation between `Density` and `SpecificVolume` (replacing the existing multiplication) - [x] adding standard multiplication for `MolarEnergy.JoulePerMole * AmountOfSubstance.Mole` (returning `Energy.Joule`) - [x] adding standard multiplication for `Illuminance.Lux * Area.SquareMeter` (returning `LuminousFlux.Lumen`) - [x] `TemperatureDelta.Kelvin * CoefficientOfThermalExpansion.PerKelvin` now returns a `Ratio` (instead of a `double`) - [x] added the `-- NoInferredDivision` to the `KinematicViscosity.SquareMeterPerSecond * Duration.Second` operator (as the opposite of the relation was `Area / Duration` -> `KinematicViscosity` 😏 ) - [x] added the `-- NoInferredDivision` to the `Area.SquareMeter * ReciprocalArea.InverseSquareMeter` operator (as the opposite of the relation was `Ratio / Area` -> `InverseArea` does not appear intuitive ) - [x] change the multiplication units (using the `BaseUnit`) for the `Mass.Kilogram = AmountOfSubstance.Mole * MolarMass.KilogramPerMole` - [x] change the multiplication units (using the `BaseUnit`) for the `AmountOfSubstance.Mole = MolarFlow.MolePerSecond * Duration.Second` I've included tests for **_all_** operators from the affected classes (_most operators, introduced with the `UnitRelations.json` were never covered by tests_). PS There are still many operators not covered by tests, but I'd rather finish them later (_hopefully once we no longer have to worry about rounding errors_). --------- Co-authored-by: Andreas Gullberg Larsen <[email protected]>
- Loading branch information
1 parent
17e3bfc
commit ef739cd
Showing
30 changed files
with
436 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Licensed under MIT No Attribution, see LICENSE file at the root. | ||
// Licensed under MIT No Attribution, see LICENSE file at the root. | ||
// Copyright 2013 Andreas Gullberg Larsen ([email protected]). Maintained at https://github.com/angularsen/UnitsNet. | ||
|
||
using System; | ||
|
@@ -191,5 +191,33 @@ public void EnergyDividedBySpecificEnergyEqualsMass() | |
Mass m = Energy.FromJoules(24) / SpecificEnergy.FromJoulesPerKilogram(8); | ||
Assert.Equal(Mass.FromKilograms(3), m); | ||
} | ||
|
||
[Fact] | ||
public void EnergyDividedByMolarEnergyEqualsAmountOfSubstance() | ||
{ | ||
AmountOfSubstance m = Energy.FromJoules(24) / MolarEnergy.FromJoulesPerMole(8); | ||
Assert.Equal(AmountOfSubstance.FromMoles(3), m); | ||
} | ||
|
||
[Fact] | ||
public void EnergyDividedByAmountOfSubstanceEqualsMolarEnergy() | ||
{ | ||
MolarEnergy m = Energy.FromJoules(24) / AmountOfSubstance.FromMoles(8); | ||
Assert.Equal(MolarEnergy.FromJoulesPerMole(3), m); | ||
} | ||
|
||
[Fact] | ||
public void EnergyDividedByVolumeEqualsEnergyDensity() | ||
{ | ||
EnergyDensity m = Energy.FromJoules(24) / Volume.FromCubicMeters(8); | ||
Assert.Equal(EnergyDensity.FromJoulesPerCubicMeter(3), m); | ||
} | ||
|
||
[Fact] | ||
public void EnergyDividedByEnergyDensityEqualsVolume() | ||
{ | ||
Volume m = Energy.FromJoules(24) / EnergyDensity.FromJoulesPerCubicMeter(8); | ||
Assert.Equal(Volume.FromCubicMeters(3), m); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.