diff --git a/UnitsNet.Tests/CustomCode/AngleTests.cs b/UnitsNet.Tests/CustomCode/AngleTests.cs index 64e6d53623..5fbe8cc085 100644 --- a/UnitsNet.Tests/CustomCode/AngleTests.cs +++ b/UnitsNet.Tests/CustomCode/AngleTests.cs @@ -20,11 +20,25 @@ // THE SOFTWARE. using System; +using NUnit.Framework; namespace UnitsNet.Tests.CustomCode { public class AngleTests : AngleTestsBase { + [Test] + public void AngleDividedByTimeSpanEqualsRotationalSpeed() + { + var rotationalSpeed = Angle.FromRadians(10)/TimeSpan.FromSeconds(5); + Assert.AreEqual(rotationalSpeed, RotationalSpeed.FromRadiansPerSecond(2)); + } + + [Test] + public void AngleDividedByDurationEqualsRotationalSpeed() + { + var rotationalSpeed = Angle.FromRadians(10) / Duration.FromSeconds(5); + Assert.AreEqual(rotationalSpeed, RotationalSpeed.FromRadiansPerSecond(2)); + } protected override double DegreesInOneDegree { @@ -33,7 +47,7 @@ protected override double DegreesInOneDegree protected override double GradiansInOneDegree { - get { return 400/360.0; } + get { return 400 / 360.0; } } protected override double ArcminutesInOneDegree @@ -46,7 +60,7 @@ protected override double ArcminutesInOneDegree protected override double RadiansInOneDegree { - get { return Math.PI/2/90; } + get { return Math.PI / 2 / 90; } } protected override double NanoradiansInOneDegree diff --git a/UnitsNet.Tests/CustomCode/AreaTests.cs b/UnitsNet.Tests/CustomCode/AreaTests.cs index 4a91355e63..ad3d03e9d1 100644 --- a/UnitsNet.Tests/CustomCode/AreaTests.cs +++ b/UnitsNet.Tests/CustomCode/AreaTests.cs @@ -19,10 +19,19 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +using NUnit.Framework; + namespace UnitsNet.Tests.CustomCode { public class AreaTests : AreaTestsBase { + [Test] + public void AreaDividedByLengthEqualsLength() + { + var length = Area.FromSquareMeters(50) / Length.FromMeters(5); + Assert.AreEqual(length, Length.FromMeters(10)); + } + protected override double SquareCentimetersInOneSquareMeter { get { return 1E4; } diff --git a/UnitsNet.Tests/CustomCode/DensityTests.cs b/UnitsNet.Tests/CustomCode/DensityTests.cs index d18721efa4..8a28353782 100644 --- a/UnitsNet.Tests/CustomCode/DensityTests.cs +++ b/UnitsNet.Tests/CustomCode/DensityTests.cs @@ -19,10 +19,26 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +using NUnit.Framework; + namespace UnitsNet.Tests.CustomCode { public class DensityTests : DensityTestsBase { + [Test] + public static void DensityTimesVolumeEqualsMass() + { + var mass = Density.FromKilogramsPerCubicMeter(2) * Volume.FromCubicMeters(3); + Assert.AreEqual(mass, Mass.FromKilograms(6)); + } + + [Test] + public static void VolumeTimesDensityEqualsMass() + { + var mass = Volume.FromCubicMeters(3) * Density.FromKilogramsPerCubicMeter(2); + Assert.AreEqual(mass, Mass.FromKilograms(6)); + } + protected override double KilogramsPerCubicCentimeterInOneKilogramPerCubicMeter { get { return 1e-6; } diff --git a/UnitsNet.Tests/CustomCode/ForceTests.cs b/UnitsNet.Tests/CustomCode/ForceTests.cs index 15d24c10d1..046e2e28a5 100644 --- a/UnitsNet.Tests/CustomCode/ForceTests.cs +++ b/UnitsNet.Tests/CustomCode/ForceTests.cs @@ -18,11 +18,36 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +using NUnit.Framework; namespace UnitsNet.Tests.CustomCode { public class ForceTests : ForceTestsBase { + [Test] + public void ForceTimesSpeedEqualsPower() + { + var power = Force.FromNewtons(27.0) * Speed.FromMetersPerSecond(10.0); + Assert.AreEqual(power, Power.FromWatts(270)); + } + [Test] + public void SpeedTimesForceEqualsPower() + { + var power = Speed.FromMetersPerSecond(10.0)* Force.FromNewtons(27.0); + Assert.AreEqual(power, Power.FromWatts(270)); + } + [Test] + public void ForceDividedByMassEqualsAcceleration() + { + var acceleration= Force.FromNewtons(27)/Mass.FromKilograms(9); + Assert.AreEqual(acceleration, Acceleration.FromMeterPerSecondSquared(3)); + } + [Test] + public void ForceDividedByAreaEqualsPressure() + { + var pressure=Force.FromNewtons(81)/Area.FromSquareMeters(9); + Assert.AreEqual(pressure, Pressure.FromNewtonsPerSquareMeter(9)); + } protected override double DyneInOneNewton { get { return 1E5; } diff --git a/UnitsNet.Tests/CustomCode/KinematicViscosityTests.cs b/UnitsNet.Tests/CustomCode/KinematicViscosityTests.cs index 6d1228fcd0..07e5b51bc0 100644 --- a/UnitsNet.Tests/CustomCode/KinematicViscosityTests.cs +++ b/UnitsNet.Tests/CustomCode/KinematicViscosityTests.cs @@ -20,12 +20,48 @@ // THE SOFTWARE. +using NUnit.Framework; using System; namespace UnitsNet.Tests.CustomCode { public class KinematicViscosityTests : KinematicViscosityTestsBase { + [Test] + public static void KinematicViscosityDividedByLengthEqualsSpeed() + { + var speed = KinematicViscosity.FromSquareMetersPerSecond(4) / Length.FromMeters(2); + Assert.AreEqual(speed, Speed.FromMetersPerSecond(2)); + } + + [Test] + public static void KinematicViscosityTimesTimeSpanEqualsArea() + { + var area = KinematicViscosity.FromSquareMetersPerSecond(4) * TimeSpan.FromSeconds(2); + Assert.AreEqual(area, Area.FromSquareMeters(8)); + } + + [Test] + public static void TimeSpanTimesKinematicViscosityEqualsArea() + { + var area = TimeSpan.FromSeconds(2) * KinematicViscosity.FromSquareMetersPerSecond(4); + Assert.AreEqual(area, Area.FromSquareMeters(8)); + } + + [Test] + public static void KinematicViscosityTimesDurationEqualsArea() + { + var area = KinematicViscosity.FromSquareMetersPerSecond(4) * Duration.FromSeconds(2); + Assert.AreEqual(area, Area.FromSquareMeters(8)); + } + + [Test] + public static void DurationTimesKinematicViscosityEqualsArea() + { + var area = Duration.FromSeconds(2) * KinematicViscosity.FromSquareMetersPerSecond(4); + Assert.AreEqual(area, Area.FromSquareMeters(8)); + } + #region Overrides of KinematicViscosityTestsBase protected override double CentistokesInOneSquareMeterPerSecond diff --git a/UnitsNet.Tests/CustomCode/LengthTests.cs b/UnitsNet.Tests/CustomCode/LengthTests.cs index 896da4f6e4..6d2e6261df 100644 --- a/UnitsNet.Tests/CustomCode/LengthTests.cs +++ b/UnitsNet.Tests/CustomCode/LengthTests.cs @@ -20,11 +20,46 @@ // THE SOFTWARE. using System; +using NUnit.Framework; namespace UnitsNet.Tests.CustomCode { public class LengthTests : LengthTestsBase { + [Test] + public void LengthTimesLengthEqualsArea() + { + var area = Length.FromMeters(10) * Length.FromMeters(2); + Assert.AreEqual(area, Area.FromSquareMeters(20)); + } + + [Test] + public void AreaTimesLengthEqualsVolume() + { + var volume = Area.FromSquareMeters(10) * Length.FromMeters(3); + Assert.AreEqual(volume, Volume.FromCubicMeters(30)); + } + [Test] + public void LengthTimesAreaEqualsVolume() + { + var volume = Length.FromMeters(3) * Area.FromSquareMeters(9); + Assert.AreEqual(volume, Volume.FromCubicMeters(27)); + } + + [Test] + public void ForceTimesLengthEqualsTorque() + { + var torque = Force.FromNewtons(1) * Length.FromMeters(3); + Assert.AreEqual(torque, Torque.FromNewtonMeters(3)); + } + + [Test] + public void LengthTimesForceEqualsTorque() + { + var torque = Length.FromMeters(3) * Force.FromNewtons(1); + Assert.AreEqual(torque, Torque.FromNewtonMeters(3)); + } + protected override double CentimetersInOneMeter { get { return 100; } @@ -90,10 +125,12 @@ protected override double YardsInOneMeter get { return 1.09361; } } + protected override double NauticalMilesInOneMeter { get { return 1.0/1852.0; } } + } } \ No newline at end of file diff --git a/UnitsNet.Tests/CustomCode/MassFlowTests.cs b/UnitsNet.Tests/CustomCode/MassFlowTests.cs index c427171e66..1c6bfebc53 100644 --- a/UnitsNet.Tests/CustomCode/MassFlowTests.cs +++ b/UnitsNet.Tests/CustomCode/MassFlowTests.cs @@ -19,22 +19,49 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. - using System; +using NUnit.Framework; +using UnitsNet.Units; namespace UnitsNet.Tests.CustomCode { public class MassFlowTests : MassFlowTestsBase { + [Test] + public void MassFlowTimesTimeSpanEqualsMass() + { + var mass = MassFlow.FromKilogramsPerSecond(20.0) * TimeSpan.FromSeconds(4.0); + Assert.AreEqual(mass, Mass.FromKilograms(80.0)); + } + [Test] + public void TimeSpanTimesMassFlowEqualsMass() + { + var mass = TimeSpan.FromSeconds(4.0) * MassFlow.FromKilogramsPerSecond(20.0); + Assert.AreEqual(mass, Mass.FromKilograms(80.0)); + } + + [Test] + public void MassFlowTimesDurationEqualsMass() + { + var mass = MassFlow.FromKilogramsPerSecond(20.0) * Duration.FromSeconds(4.0); + Assert.AreEqual(mass, Mass.FromKilograms(80.0)); + } + [Test] + public void DurationTimesMassFlowEqualsMass() + { + var mass = Duration.FromSeconds(4.0) * MassFlow.FromKilogramsPerSecond(20.0); + Assert.AreEqual(mass, Mass.FromKilograms(80.0)); + } + protected override double GramsPerSecondInOneGramPerSecond { get { return 1; } } protected override double DecagramsPerSecondInOneGramPerSecond - { + { get { return 1E-1; } - } + } protected override double HectogramsPerSecondInOneGramPerSecond { diff --git a/UnitsNet.Tests/CustomCode/MassTests.cs b/UnitsNet.Tests/CustomCode/MassTests.cs index f7a8f6ca0c..cfbc286a03 100644 --- a/UnitsNet.Tests/CustomCode/MassTests.cs +++ b/UnitsNet.Tests/CustomCode/MassTests.cs @@ -18,11 +18,48 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +using NUnit.Framework; +using System; namespace UnitsNet.Tests.CustomCode { public class MassTests : MassTestsBase { + [Test] + public void MassDividedByTimeSpanEqualsMassFlow() + { + var massFlow= Mass.FromKilograms(18.0) / TimeSpan.FromSeconds(6); + Assert.AreEqual(massFlow, MassFlow.FromKilogramsPerSecond(3.0)); + } + + [Test] + public void MassDividedByDurationEqualsMassFlow() + { + var massFlow = Mass.FromKilograms(18.0) / Duration.FromSeconds(6); + Assert.AreEqual(massFlow, MassFlow.FromKilogramsPerSecond(3.0)); + } + + [Test] + public void MassDividedByVolumeEqualsDensity() + { + var density = Mass.FromKilograms(18) / Volume.FromCubicMeters(3); + Assert.AreEqual(density, Density.FromKilogramsPerCubicMeter(6)); + } + + [Test] + public void MassTimesAccelerationEqualsForce() + { + var force = Mass.FromKilograms(18) * Acceleration.FromMeterPerSecondSquared(3); + Assert.AreEqual(force, Force.FromNewtons(54)); + } + + [Test] + public void AccelerationTimesMassEqualsForce() + { + var force = Acceleration.FromMeterPerSecondSquared(3) * Mass.FromKilograms(18); + Assert.AreEqual(force, Force.FromNewtons(54)); + } + protected override double CentigramsInOneKilogram { get { return 1E5; } diff --git a/UnitsNet.Tests/CustomCode/PowerTests.cs b/UnitsNet.Tests/CustomCode/PowerTests.cs index 8fc9584039..7b2598a2ac 100644 --- a/UnitsNet.Tests/CustomCode/PowerTests.cs +++ b/UnitsNet.Tests/CustomCode/PowerTests.cs @@ -18,11 +18,57 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +using NUnit.Framework; +using System; namespace UnitsNet.Tests.CustomCode { public class PowerTests : PowerTestsBase { + [Test] + public void PowerDividedBySpeedEqualsForce() + { + var force= Power.FromWatts(15.0) / Speed.FromMetersPerSecond(3); + Assert.AreEqual(force, Force.FromNewtons(5)); + } + [Test] + public void PowerDividedByRotationalSpeedEqualsForce() + { + var torque = Power.FromWatts(15.0) / RotationalSpeed.FromRadiansPerSecond(3); + Assert.AreEqual(torque, Torque.FromNewtonMeters(5)); + } + [Test] + public void PowerDividedByTorqueEqualsRotationalSpeed() + { + var rotationalSpeed= Power.FromWatts(15.0) / Torque.FromNewtonMeters(3); + Assert.AreEqual(rotationalSpeed, RotationalSpeed.FromRadiansPerSecond(5)); + } + [Test] + public void PowerTimesTimeSpanEqualsEnergy() + { + var energy = Power.FromWatts(5.0)*TimeSpan.FromSeconds(8.0); + Assert.AreEqual(energy, Energy.FromJoules(40.0)); + } + [Test] + public void TimeSpanTimesPowerEqualsEnergy() + { + var energy = TimeSpan.FromSeconds(8.0)* Power.FromWatts(5.0); + Assert.AreEqual(energy, Energy.FromJoules(40.0)); + } + + [Test] + public void PowerTimesDurationEqualsEnergy() + { + var energy = Power.FromWatts(5.0) * Duration.FromSeconds(8.0); + Assert.AreEqual(energy, Energy.FromJoules(40.0)); + } + [Test] + public void DurationTimesPowerEqualsEnergy() + { + var energy = Duration.FromSeconds(8.0) * Power.FromWatts(5.0); + Assert.AreEqual(energy, Energy.FromJoules(40.0)); + } + protected override double FemtowattsInOneWatt { get { return 1e15; } diff --git a/UnitsNet.Tests/CustomCode/PressureTests.cs b/UnitsNet.Tests/CustomCode/PressureTests.cs index f48239f37f..2d15add7dd 100644 --- a/UnitsNet.Tests/CustomCode/PressureTests.cs +++ b/UnitsNet.Tests/CustomCode/PressureTests.cs @@ -18,11 +18,26 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +using NUnit.Framework; namespace UnitsNet.Tests.CustomCode { public class PressureTests : PressureTestsBase { + [Test] + public void PressureTimesAreaEqualsForce() + { + var force = Pressure.FromPascals(20) * Area.FromSquareMeters(3); + Assert.AreEqual(force, Force.FromNewtons(60)); + } + + [Test] + public void AreaTimesPressureEqualsForce() + { + var force = Area.FromSquareMeters(3) * Pressure.FromPascals(20); + Assert.AreEqual(force, Force.FromNewtons(60)); + } + protected override double AtmospheresInOnePascal { get { return 9.8692*1E-6; } diff --git a/UnitsNet.Tests/CustomCode/RotationalSpeedTests.cs b/UnitsNet.Tests/CustomCode/RotationalSpeedTests.cs index 3fd2d844d5..ef4cab1214 100644 --- a/UnitsNet.Tests/CustomCode/RotationalSpeedTests.cs +++ b/UnitsNet.Tests/CustomCode/RotationalSpeedTests.cs @@ -20,11 +20,40 @@ // THE SOFTWARE. using System; +using NUnit.Framework; namespace UnitsNet.Tests.CustomCode { + public class RotationalSpeedTests : RotationalSpeedTestsBase { + [Test] + public void RotationalSpeedTimesTimeSpanEqualsAngle() + { + var angle = RotationalSpeed.FromRadiansPerSecond(10.0) * TimeSpan.FromSeconds(9.0); + Assert.AreEqual(angle, Angle.FromRadians(90.0)); + } + + [Test] + public void TimeSpanTimesRotationalSpeedEqualsAngle() + { + var angle = TimeSpan.FromSeconds(9.0) * RotationalSpeed.FromRadiansPerSecond(10.0) ; + Assert.AreEqual(angle, Angle.FromRadians(90.0)); + } + + [Test] + public void RotationalSpeedTimesDurationEqualsAngle() + { + var angle = RotationalSpeed.FromRadiansPerSecond(10.0) * Duration.FromSeconds(9.0); + Assert.AreEqual(angle, Angle.FromRadians(90.0)); + } + + [Test] + public void DurationTimesRotationalSpeedEqualsAngle() + { + var angle = Duration.FromSeconds(9.0) * RotationalSpeed.FromRadiansPerSecond(10.0); + Assert.AreEqual(angle, Angle.FromRadians(90.0)); + } protected override double RadiansPerSecondInOneRadianPerSecond { @@ -32,9 +61,9 @@ protected override double RadiansPerSecondInOneRadianPerSecond } protected override double DeciradiansPerSecondInOneRadianPerSecond - { + { get { return 1E1; } - } + } protected override double CentiradiansPerSecondInOneRadianPerSecond { @@ -54,7 +83,7 @@ protected override double MicroradiansPerSecondInOneRadianPerSecond protected override double NanoradiansPerSecondInOneRadianPerSecond { get { return 1E9; } - } + } protected override double RevolutionsPerMinuteInOneRadianPerSecond { diff --git a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs index aec916542e..eb96c06e51 100644 --- a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs +++ b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs @@ -21,11 +21,27 @@ using System; +using NUnit.Framework; namespace UnitsNet.Tests.CustomCode { public class SpecificEnergyTests : SpecificEnergyTestsBase { + + [Test] + public void SpecificEnergyTimesMassEqualsEnergy() + { + var energy = SpecificEnergy.FromJoulesPerKilogram(10.0) * Mass.FromKilograms(20.0); + Assert.AreEqual(energy, Energy.FromJoules(200.0)); + } + [Test] + public void MassTimesSpecificEnergyEqualsEnergy() + { + var energy = Mass.FromKilograms(20.0)* SpecificEnergy.FromJoulesPerKilogram(10.0); + Assert.AreEqual(energy, Energy.FromJoules(200.0)); + } + + protected override double JoulesPerKilogramInOneJoulePerKilogram { get @@ -90,5 +106,6 @@ protected override double WattHoursPerKilogramInOneJoulePerKilogram return 1.0 / 3.6e3; } } + } } diff --git a/UnitsNet.Tests/CustomCode/SpeedTests.cs b/UnitsNet.Tests/CustomCode/SpeedTests.cs index ec3c549715..b2ab7cf06a 100644 --- a/UnitsNet.Tests/CustomCode/SpeedTests.cs +++ b/UnitsNet.Tests/CustomCode/SpeedTests.cs @@ -20,11 +20,67 @@ // THE SOFTWARE. using System; +using NUnit.Framework; namespace UnitsNet.Tests.CustomCode { public class SpeedTests : SpeedTestsBase { + [Test] + public void SpeedDividedByTimeSpanEqualsAcceleration() + { + var acceleration = Speed.FromMetersPerSecond(20) / TimeSpan.FromSeconds(2); + Assert.AreEqual(acceleration, Acceleration.FromMeterPerSecondSquared(10)); + } + + [Test] + public void SpeedTimesTimeSpanEqualsLength() + { + var length= Speed.FromMetersPerSecond(20) * TimeSpan.FromSeconds(2); + Assert.AreEqual(length, Length.FromMeters(40)); + } + + [Test] + public void SpeedDividedByDurationEqualsAcceleration() + { + var acceleration = Speed.FromMetersPerSecond(20) / Duration.FromSeconds(2); + Assert.AreEqual(acceleration, Acceleration.FromMeterPerSecondSquared(10)); + } + + [Test] + public void SpeedTimesDurationEqualsLength() + { + var length = Speed.FromMetersPerSecond(20) * Duration.FromSeconds(2); + Assert.AreEqual(length, Length.FromMeters(40)); + } + + [Test] + public void TimeSpanTimesSpeedEqualsLength() + { + var length = TimeSpan.FromSeconds(2) * Speed.FromMetersPerSecond(20); + Assert.AreEqual(length, Length.FromMeters(40)); + } + + [Test] + public void LengthDividedByTimeSpanEqualsSpeed() + { + var speed = Length.FromMeters(20) / TimeSpan.FromSeconds(2); + Assert.AreEqual(speed, Speed.FromMetersPerSecond(10)); + } + + [Test] + public void DurationSpeedTimesEqualsLength() + { + var length = Duration.FromSeconds(2) * Speed.FromMetersPerSecond(20); + Assert.AreEqual(length, Length.FromMeters(40)); + } + + [Test] + public void LengthDividedByDurationEqualsSpeed() + { + var speed = Length.FromMeters(20) / Duration.FromSeconds(2); + Assert.AreEqual(speed, Speed.FromMetersPerSecond(10)); + } protected override double FeetPerSecondInOneMeterPerSecond { diff --git a/UnitsNet.Tests/CustomCode/TorqueTests.cs b/UnitsNet.Tests/CustomCode/TorqueTests.cs index 1de0635088..44c78994c1 100644 --- a/UnitsNet.Tests/CustomCode/TorqueTests.cs +++ b/UnitsNet.Tests/CustomCode/TorqueTests.cs @@ -18,11 +18,25 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +using NUnit.Framework; namespace UnitsNet.Tests.CustomCode { public class TorqueTests : TorqueTestsBase { + [Test] + public void TorqueDividedByLengthEqualsForce() + { + var force = Torque.FromNewtonMeters(4) / Length.FromMeters(2); + Assert.AreEqual(force, Force.FromNewtons(2)); + } + [Test] + public void TorqueDividedByForceEqualsLength() + { + var length= Torque.FromNewtonMeters(4) / Force.FromNewtons(2); + Assert.AreEqual(length, Length.FromMeters(2)); + } + protected override double KilogramForceCentimetersInOneNewtonMeter { get { return 10.1971621; } diff --git a/UnitsNet.Tests/CustomCode/VolumeTests.cs b/UnitsNet.Tests/CustomCode/VolumeTests.cs index a41f21ec79..df84426c8b 100644 --- a/UnitsNet.Tests/CustomCode/VolumeTests.cs +++ b/UnitsNet.Tests/CustomCode/VolumeTests.cs @@ -19,10 +19,33 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +using NUnit.Framework; + namespace UnitsNet.Tests.CustomCode { public class VolumeTests : VolumeTestsBase { + [Test] + public void VolumeDividedByLengthEqualsArea() + { + var area = Volume.FromCubicMeters(15) / Length.FromMeters(5); + Assert.AreEqual(area, Area.FromSquareMeters(3)); + } + + [Test] + public void VolumeDividedByAreaEqualsLength() + { + var length= Volume.FromCubicMeters(15) / Area.FromSquareMeters(5); + Assert.AreEqual(length, Length.FromMeters(3)); + } + + [Test] + public void VolumeTimesDensityEqualsMass() + { + var mass = Volume.FromCubicMeters(2) * Density.FromKilogramsPerCubicMeter(3); + Assert.AreEqual(mass, Mass.FromKilograms(6)); + } + protected override double CentilitersInOneCubicMeter { get { return 1E5; } diff --git a/UnitsNet/CustomCode/UnitClasses/Angle.extra.cs b/UnitsNet/CustomCode/UnitClasses/Angle.extra.cs new file mode 100644 index 0000000000..c4f65cebb7 --- /dev/null +++ b/UnitsNet/CustomCode/UnitClasses/Angle.extra.cs @@ -0,0 +1,38 @@ +// Copyright © 2007 by Initial Force AS. All rights reserved. +// https://github.com/InitialForce/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace UnitsNet +{ + public partial struct Angle + { + public static RotationalSpeed operator /(Angle angle, TimeSpan timeSpan) + { + return RotationalSpeed.FromRadiansPerSecond(angle.Radians / timeSpan.TotalSeconds); + } + + public static RotationalSpeed operator /(Angle angle, Duration duration) + { + return RotationalSpeed.FromRadiansPerSecond(angle.Radians / duration.Seconds); + } + } +} diff --git a/UnitsNet/CustomCode/UnitClasses/Area.extra.cs b/UnitsNet/CustomCode/UnitClasses/Area.extra.cs new file mode 100644 index 0000000000..1998ef2c0e --- /dev/null +++ b/UnitsNet/CustomCode/UnitClasses/Area.extra.cs @@ -0,0 +1,32 @@ +// Copyright © 2007 by Initial Force AS. All rights reserved. +// https://github.com/InitialForce/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +namespace UnitsNet +{ + public partial struct Area + { + public static Length operator/(Area area, Length length) + { + return Length.FromMeters(area.SquareMeters / length.Meters); + } + + } +} diff --git a/UnitsNet/CustomCode/UnitClasses/Density.extra.cs b/UnitsNet/CustomCode/UnitClasses/Density.extra.cs new file mode 100644 index 0000000000..d3dce43785 --- /dev/null +++ b/UnitsNet/CustomCode/UnitClasses/Density.extra.cs @@ -0,0 +1,37 @@ +// Copyright © 2007 by Initial Force AS. All rights reserved. +// https://github.com/InitialForce/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +namespace UnitsNet +{ + public partial struct Density + { + public static Mass operator *(Density density, Volume volume) + { + return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); + } + + public static Mass operator *(Volume volume, Density density) + { + return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); + } + } +} + diff --git a/UnitsNet/CustomCode/UnitClasses/Force.extra.cs b/UnitsNet/CustomCode/UnitClasses/Force.extra.cs index 39f553c1e2..10e0e4f622 100644 --- a/UnitsNet/CustomCode/UnitClasses/Force.extra.cs +++ b/UnitsNet/CustomCode/UnitClasses/Force.extra.cs @@ -23,6 +23,23 @@ namespace UnitsNet { public partial struct Force { + public static Power operator*(Force force, Speed speed) + { + return Power.FromWatts(force.Newtons * speed.MetersPerSecond); + } + public static Power operator *(Speed speed, Force force) + { + return Power.FromWatts(force.Newtons * speed.MetersPerSecond); + } + public static Acceleration operator /(Force force, Mass mass) + { + return Acceleration.FromMeterPerSecondSquared(force.Newtons / mass.Kilograms); + } + public static Pressure operator /(Force force, Area area) + { + return Pressure.FromPascals(force.Newtons / area.SquareMeters); + } + public static Force FromPressureByArea(Pressure p, Length2d area) { double metersSquared = area.Meters.X*area.Meters.Y; diff --git a/UnitsNet/CustomCode/UnitClasses/KinematicViscosity.extra.cs b/UnitsNet/CustomCode/UnitClasses/KinematicViscosity.extra.cs new file mode 100644 index 0000000000..dfad665249 --- /dev/null +++ b/UnitsNet/CustomCode/UnitClasses/KinematicViscosity.extra.cs @@ -0,0 +1,54 @@ +// Copyright © 2007 by Initial Force AS. All rights reserved. +// https://github.com/InitialForce/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace UnitsNet +{ + public partial struct KinematicViscosity + { + public static Speed operator /(KinematicViscosity kinematicViscosity, Length length) + { + return Speed.FromMetersPerSecond(kinematicViscosity.SquareMetersPerSecond / length.Meters); + } + + public static Area operator *(KinematicViscosity kinematicViscosity, TimeSpan timeSpan) + { + return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * timeSpan.TotalSeconds); + } + + public static Area operator *(TimeSpan timeSpan, KinematicViscosity kinematicViscosity) + { + return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * timeSpan.TotalSeconds); + } + + public static Area operator *(KinematicViscosity kinematicViscosity, Duration duration) + { + return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * duration.Seconds); + } + + public static Area operator *(Duration duration, KinematicViscosity kinematicViscosity) + { + return Area.FromSquareMeters(kinematicViscosity.SquareMetersPerSecond * duration.Seconds); + } + } +} + diff --git a/UnitsNet/CustomCode/UnitClasses/Length.extra.cs b/UnitsNet/CustomCode/UnitClasses/Length.extra.cs index 202e091720..898d07c7ad 100644 --- a/UnitsNet/CustomCode/UnitClasses/Length.extra.cs +++ b/UnitsNet/CustomCode/UnitClasses/Length.extra.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; -using System.Text; using UnitsNet.Units; namespace UnitsNet @@ -21,7 +18,8 @@ public partial struct Length /// public FeetInches FeetInches { - get { + get + { double totalInches = Inches; double wholeFeet = Math.Floor(totalInches / FeetToInches); double inches = totalInches % FeetToInches; @@ -37,6 +35,39 @@ public static Length FromFeetInches(double feet, double inches) { return FromInches((FeetToInches * feet) + inches); } + + public static Speed operator/ (Length length, TimeSpan timeSpan) + { + return Speed.FromMetersPerSecond(length.Meters / timeSpan.TotalSeconds); + } + + public static Speed operator /(Length length, Duration duration) + { + return Speed.FromMetersPerSecond(length.Meters / duration.Seconds); + } + + public static Area operator*(Length length1, Length length2) + { + return Area.FromSquareMeters(length1.Meters * length2.Meters); + } + public static Volume operator*(Area area, Length length) + { + return Volume.FromCubicMeters(area.SquareMeters * length.Meters); + } + public static Volume operator *(Length length, Area area) + { + return Volume.FromCubicMeters(area.SquareMeters * length.Meters); + } + public static Torque operator*(Force force, Length length) + { + return Torque.FromNewtonMeters(force.Newtons * length.Meters); + } + + public static Torque operator *(Length length, Force force) + { + return Torque.FromNewtonMeters(force.Newtons * length.Meters); + } + } public class FeetInches diff --git a/UnitsNet/CustomCode/UnitClasses/Mass.extra.cs b/UnitsNet/CustomCode/UnitClasses/Mass.extra.cs index 276ee959a0..ba21f3a48f 100644 --- a/UnitsNet/CustomCode/UnitClasses/Mass.extra.cs +++ b/UnitsNet/CustomCode/UnitClasses/Mass.extra.cs @@ -61,6 +61,31 @@ public static Mass FromStonePounds(double stone, double pounds) { return FromPounds((StoneToPounds * stone) + pounds); } + + public static MassFlow operator/(Mass mass, TimeSpan timeSpan) + { + return MassFlow.FromKilogramsPerSecond(mass.Kilograms / timeSpan.TotalSeconds); + } + + public static MassFlow operator /(Mass mass, Duration duration) + { + return MassFlow.FromKilogramsPerSecond(mass.Kilograms / duration.Seconds); + } + + public static Density operator /(Mass mass, Volume volume) + { + return Density.FromKilogramsPerCubicMeter(mass.Kilograms / volume.CubicMeters); + } + + public static Force operator *(Mass mass, Acceleration acceleration) + { + return Force.FromNewtons(mass.Kilograms * acceleration.MeterPerSecondSquared); + } + + public static Force operator *(Acceleration acceleration, Mass mass) + { + return Force.FromNewtons(mass.Kilograms * acceleration.MeterPerSecondSquared); + } } public class StonePounds diff --git a/UnitsNet/CustomCode/UnitClasses/MassFlow.extra.cs b/UnitsNet/CustomCode/UnitClasses/MassFlow.extra.cs new file mode 100644 index 0000000000..8c87398640 --- /dev/null +++ b/UnitsNet/CustomCode/UnitClasses/MassFlow.extra.cs @@ -0,0 +1,47 @@ +// Copyright © 2007 by Initial Force AS. All rights reserved. +// https://github.com/InitialForce/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace UnitsNet +{ + public partial struct MassFlow + { + + public static Mass operator *(MassFlow massFlow, TimeSpan time) + { + return Mass.FromKilograms(massFlow.KilogramsPerSecond * time.TotalSeconds); + } + public static Mass operator *(TimeSpan time, MassFlow massFlow) + { + return Mass.FromKilograms(massFlow.KilogramsPerSecond * time.TotalSeconds); + } + + public static Mass operator *(MassFlow massFlow, Duration duration) + { + return Mass.FromKilograms(massFlow.KilogramsPerSecond * duration.Seconds); + } + public static Mass operator *(Duration duration, MassFlow massFlow) + { + return Mass.FromKilograms(massFlow.KilogramsPerSecond * duration.Seconds); + } + } +} diff --git a/UnitsNet/CustomCode/UnitClasses/Power.extra.cs b/UnitsNet/CustomCode/UnitClasses/Power.extra.cs new file mode 100644 index 0000000000..a7ecf34918 --- /dev/null +++ b/UnitsNet/CustomCode/UnitClasses/Power.extra.cs @@ -0,0 +1,69 @@ +// Copyright © 2007 by Initial Force AS. All rights reserved. +// https://github.com/InitialForce/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace UnitsNet +{ + /// + /// Extension to the generated Length struct. + /// Makes it easier to work with Feet/Inches combinations, which are customarily used in the US and UK + /// to express body height. For example, someone is 5 feet 3 inches tall. + /// + public partial struct Power + { + public static Energy operator*(Power power, TimeSpan time) + { + return Energy.FromJoules(power.Watts* time.TotalSeconds); + } + + public static Energy operator *(TimeSpan time, Power power) + { + return Energy.FromJoules(power.Watts * time.TotalSeconds); + } + + public static Energy operator *(Power power, Duration duration) + { + return Energy.FromJoules(power.Watts * duration.Seconds); + } + + public static Energy operator *(Duration duration, Power power) + { + return Energy.FromJoules(power.Watts * duration.Seconds); + } + + public static Force operator/(Power power, Speed speed) + { + return Force.FromNewtons(power.Watts / speed.MetersPerSecond); + } + + public static Torque operator /(Power power, RotationalSpeed rotationalSpeed) + { + return Torque.FromNewtonMeters(power.Watts / rotationalSpeed.RadiansPerSecond); + } + + public static RotationalSpeed operator/(Power power, Torque torque) + { + return RotationalSpeed.FromRadiansPerSecond(power.Watts / torque.NewtonMeters); + } + + } +} diff --git a/UnitsNet/CustomCode/UnitClasses/Pressure.extra.cs b/UnitsNet/CustomCode/UnitClasses/Pressure.extra.cs new file mode 100644 index 0000000000..58e8cfb38e --- /dev/null +++ b/UnitsNet/CustomCode/UnitClasses/Pressure.extra.cs @@ -0,0 +1,36 @@ +// Copyright © 2007 by Initial Force AS. All rights reserved. +// https://github.com/InitialForce/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +namespace UnitsNet +{ + public partial struct Pressure + { + public static Force operator*(Pressure pressure, Area area) + { + return Force.FromNewtons(pressure.Pascals * area.SquareMeters); + } + + public static Force operator *(Area area, Pressure pressure) + { + return Force.FromNewtons(pressure.Pascals * area.SquareMeters); + } + } +} diff --git a/UnitsNet/CustomCode/UnitClasses/RotationalSpeed.extra.cs b/UnitsNet/CustomCode/UnitClasses/RotationalSpeed.extra.cs new file mode 100644 index 0000000000..b3dd40faa7 --- /dev/null +++ b/UnitsNet/CustomCode/UnitClasses/RotationalSpeed.extra.cs @@ -0,0 +1,48 @@ +// Copyright © 2007 by Initial Force AS. All rights reserved. +// https://github.com/InitialForce/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace UnitsNet +{ + public partial struct RotationalSpeed + { + public static Angle operator *(RotationalSpeed rotationalSpeed, TimeSpan timeSpan) + { + return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * timeSpan.TotalSeconds); + } + + public static Angle operator *(TimeSpan timeSpan, RotationalSpeed rotationalSpeed) + { + return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * timeSpan.TotalSeconds); + } + + public static Angle operator *(RotationalSpeed rotationalSpeed, Duration duration) + { + return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * duration.Seconds); + } + + public static Angle operator *(Duration duration, RotationalSpeed rotationalSpeed) + { + return Angle.FromRadians(rotationalSpeed.RadiansPerSecond * duration.Seconds); + } + } +} diff --git a/UnitsNet/CustomCode/UnitClasses/SpecificEnergy.extra.cs b/UnitsNet/CustomCode/UnitClasses/SpecificEnergy.extra.cs new file mode 100644 index 0000000000..75fb518852 --- /dev/null +++ b/UnitsNet/CustomCode/UnitClasses/SpecificEnergy.extra.cs @@ -0,0 +1,35 @@ +// Copyright © 2007 by Initial Force AS. All rights reserved. +// https://github.com/InitialForce/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +namespace UnitsNet +{ + public partial struct SpecificEnergy + { + public static Energy operator*(SpecificEnergy specificEnergy, Mass mass) + { + return Energy.FromJoules(specificEnergy.JoulesPerKilogram * mass.Kilograms); + } + public static Energy operator *(Mass mass, SpecificEnergy specificEnergy) + { + return Energy.FromJoules(specificEnergy.JoulesPerKilogram * mass.Kilograms); + } + } +} diff --git a/UnitsNet/CustomCode/UnitClasses/Speed.extra.cs b/UnitsNet/CustomCode/UnitClasses/Speed.extra.cs new file mode 100644 index 0000000000..4f3080ee07 --- /dev/null +++ b/UnitsNet/CustomCode/UnitClasses/Speed.extra.cs @@ -0,0 +1,59 @@ +// Copyright © 2007 by Initial Force AS. All rights reserved. +// https://github.com/InitialForce/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +using System; + +namespace UnitsNet +{ + public partial struct Speed + { + + public static Acceleration operator /(Speed speed, TimeSpan timeSpan) + { + return Acceleration.FromMeterPerSecondSquared(speed.MetersPerSecond / timeSpan.TotalSeconds); + } + + public static Length operator *(Speed speed, TimeSpan timeSpan) + { + return Length.FromMeters(speed.MetersPerSecond * timeSpan.TotalSeconds); + } + + public static Length operator *(TimeSpan timeSpan, Speed speed) + { + return Length.FromMeters(speed.MetersPerSecond * timeSpan.TotalSeconds); + } + + public static Acceleration operator /(Speed speed, Duration duration) + { + return Acceleration.FromMeterPerSecondSquared(speed.MetersPerSecond / duration.Seconds); + } + + public static Length operator *(Speed speed, Duration duration) + { + return Length.FromMeters(speed.MetersPerSecond * duration.Seconds); + } + + public static Length operator *(Duration duration, Speed speed) + { + return Length.FromMeters(speed.MetersPerSecond * duration.Seconds); + } + } +} diff --git a/UnitsNet/CustomCode/UnitClasses/Torque.extra.cs b/UnitsNet/CustomCode/UnitClasses/Torque.extra.cs new file mode 100644 index 0000000000..17b5cd8770 --- /dev/null +++ b/UnitsNet/CustomCode/UnitClasses/Torque.extra.cs @@ -0,0 +1,35 @@ +// Copyright © 2007 by Initial Force AS. All rights reserved. +// https://github.com/InitialForce/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +namespace UnitsNet +{ + public partial struct Torque + { + public static Force operator /(Torque torque, Length length) + { + return Force.FromNewtons(torque.NewtonMeters/length.Meters); + } + public static Length operator /(Torque torque, Force force) + { + return Length.FromMeters(torque.NewtonMeters / force.Newtons); + } + } +} diff --git a/UnitsNet/CustomCode/UnitClasses/Volume.extra.cs b/UnitsNet/CustomCode/UnitClasses/Volume.extra.cs new file mode 100644 index 0000000000..9af15083cb --- /dev/null +++ b/UnitsNet/CustomCode/UnitClasses/Volume.extra.cs @@ -0,0 +1,37 @@ +// Copyright © 2007 by Initial Force AS. All rights reserved. +// https://github.com/InitialForce/UnitsNet +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +namespace UnitsNet +{ + public partial struct Volume + { + public static Area operator /(Volume volume, Length length) + { + return Area.FromSquareMeters(volume.CubicMeters / length.Meters); + } + + public static Length operator /(Volume volume, Area area) + { + return Length.FromMeters(volume.CubicMeters / area.SquareMeters); + } + + } +} diff --git a/UnitsNet/Scripts/UnitDefinitions/SpecificEnergy.json b/UnitsNet/Scripts/UnitDefinitions/SpecificEnergy.json index 8431ee10cc..91018d4b6b 100644 --- a/UnitsNet/Scripts/UnitDefinitions/SpecificEnergy.json +++ b/UnitsNet/Scripts/UnitDefinitions/SpecificEnergy.json @@ -2,7 +2,7 @@ "Name": "SpecificEnergy", "BaseUnit": "JoulePerKilogram", "XmlDoc": "The SpecificEnergy", - "XmlDocRemarks": "https://en.wikipedia.org/wiki/Specific_energy", + "XmlDocRemarks": "https://en.wikipedia.org/wiki/Specific_energy", "Units": [ { "SingularName": "JoulePerKilogram",