diff --git a/UnitsNet.Tests/CustomCode/DurationTests.cs b/UnitsNet.Tests/CustomCode/DurationTests.cs index 40dafa5691..73818e0407 100644 --- a/UnitsNet.Tests/CustomCode/DurationTests.cs +++ b/UnitsNet.Tests/CustomCode/DurationTests.cs @@ -199,5 +199,12 @@ public void DurationTimesAcceleration() Speed speed = Duration.FromSeconds(10) * Acceleration.FromMetersPerSecondSquared(10); Assert.Equal(Speed.FromMetersPerSecond(100), speed); } + + [Fact] + public void DurationTimesForceChangeRate() + { + Force force = Duration.FromSeconds(10) * ForceChangeRate.FromNewtonsPerSecond(100); + Assert.Equal(Force.FromNewtons(1000), force); + } } } diff --git a/UnitsNet.Tests/CustomCode/ForceChangeRateTests.cs b/UnitsNet.Tests/CustomCode/ForceChangeRateTests.cs index 0dddcebeb3..fb0f477091 100644 --- a/UnitsNet.Tests/CustomCode/ForceChangeRateTests.cs +++ b/UnitsNet.Tests/CustomCode/ForceChangeRateTests.cs @@ -1,6 +1,8 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. +using Xunit; + namespace UnitsNet.Tests.CustomCode { public class ForceChangeRateTests : ForceChangeRateTestsBase @@ -21,5 +23,12 @@ public class ForceChangeRateTests : ForceChangeRateTestsBase protected override double MillinewtonsPerSecondInOneNewtonPerSecond => 1E3; protected override double MicronewtonsPerSecondInOneNewtonPerSecond => 1E6; protected override double NanonewtonsPerSecondInOneNewtonPerSecond => 1E9; + + [Fact] + public void DurationTimesForceChangeRate() + { + Force force = ForceChangeRate.FromNewtonsPerSecond(100) * Duration.FromSeconds(10); + Assert.Equal(Force.FromNewtons(1000), force); + } } } diff --git a/UnitsNet.Tests/CustomCode/ForceTests.cs b/UnitsNet.Tests/CustomCode/ForceTests.cs index 90e4b588c2..7d010ee842 100644 --- a/UnitsNet.Tests/CustomCode/ForceTests.cs +++ b/UnitsNet.Tests/CustomCode/ForceTests.cs @@ -97,5 +97,12 @@ public void ForceTimesReciprocalAreaEqualsPressure() Pressure pressure = Force.FromNewtons(2) * ReciprocalArea.FromInverseSquareMeters(25); Assert.Equal(pressure, Pressure.FromNewtonsPerSquareMeter(50)); } + + [Fact] + public void ForceDividedByForceChangeRateEqualsDuration() + { + Duration duration = Force.FromNewtons(200) / ForceChangeRate.FromNewtonsPerSecond(50); + Assert.Equal(duration, Duration.FromSeconds(4)); + } } } diff --git a/UnitsNet/CustomCode/Quantities/Duration.extra.cs b/UnitsNet/CustomCode/Quantities/Duration.extra.cs index cb17556515..8af3e71c2a 100644 --- a/UnitsNet/CustomCode/Quantities/Duration.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Duration.extra.cs @@ -2,6 +2,7 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; +using UnitsNet.Units; namespace UnitsNet { @@ -92,24 +93,28 @@ public static explicit operator Duration(TimeSpan duration) return timeSpan.TotalSeconds >= duration.Seconds; } - /// Get from times . + /// Get from multiplied by . public static Volume operator *(Duration duration, VolumeFlow volumeFlow) { return Volume.FromCubicMeters(volumeFlow.CubicMetersPerSecond * duration.Seconds); } - /// Calculate from multiplied by . + /// Get from multiplied by . public static ElectricCharge operator *(Duration time, ElectricCurrent current) { return ElectricCharge.FromAmpereHours(current.Amperes * time.Hours); } - /// - /// Multiply and to get . - /// + /// Get from multiplied by . public static Speed operator *(Duration duration, Acceleration acceleration) { - return new Speed(acceleration.MetersPerSecondSquared * duration.Seconds, UnitsNet.Units.SpeedUnit.MeterPerSecond); + return new Speed(acceleration.MetersPerSecondSquared * duration.Seconds, SpeedUnit.MeterPerSecond); + } + + /// Get from multiplied by . + public static Force operator *(Duration duration, ForceChangeRate forceChangeRate) + { + return new Force(forceChangeRate.NewtonsPerSecond * duration.Seconds, ForceUnit.Newton); } } } diff --git a/UnitsNet/CustomCode/Quantities/Force.extra.cs b/UnitsNet/CustomCode/Quantities/Force.extra.cs index 67d738d97b..7972c0f412 100644 --- a/UnitsNet/CustomCode/Quantities/Force.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Force.extra.cs @@ -67,5 +67,11 @@ public static Force FromMassByAcceleration(Mass mass, Acceleration acceleration) { return ForcePerLength.FromNewtonsPerMeter(force.Newtons / length.Meters); } + + /// Get from divided by . + public static Duration operator /(Force force, ForceChangeRate forceChangeRate) + { + return new Duration(force.Newtons / forceChangeRate.NewtonsPerSecond, DurationUnit.Second); + } } } diff --git a/UnitsNet/CustomCode/Quantities/ForceChangeRate.extra.cs b/UnitsNet/CustomCode/Quantities/ForceChangeRate.extra.cs new file mode 100644 index 0000000000..4880daadde --- /dev/null +++ b/UnitsNet/CustomCode/Quantities/ForceChangeRate.extra.cs @@ -0,0 +1,16 @@ +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using UnitsNet.Units; + +namespace UnitsNet +{ + public partial struct ForceChangeRate + { + /// Get from multiplied by . + public static Force operator *(ForceChangeRate forceChangeRate, Duration duration) + { + return new Force(forceChangeRate.NewtonsPerSecond * duration.Seconds, ForceUnit.Newton); + } + } +}