-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
operator overloads for ElectricCurrentGradient and time to ElectricCu…
…rrent and PressureChangeRate and Time to Pressure
- Loading branch information
1 parent
7d772b3
commit cf1b16c
Showing
8 changed files
with
137 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
// 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; | ||
|
||
using Xunit; | ||
|
||
namespace UnitsNet.Tests | ||
|
@@ -52,5 +54,19 @@ public void ElectricCurrentMultipliedByDurationEqualsElectricCharge() | |
ElectricCharge ah = ElectricCurrent.FromAmperes(4) * Duration.FromHours(5); | ||
Assert.Equal(20, ah.AmpereHours); | ||
} | ||
|
||
[Fact] | ||
public void ElectricCurrentDividedByDurationEqualsElectricCurrentGradient() | ||
{ | ||
ElectricCurrentGradient electricCurrentGradient = ElectricCurrent.FromAmperes(10) / Duration.FromSeconds(2); | ||
Assert.Equal(ElectricCurrentGradient.FromAmperesPerSecond(5), electricCurrentGradient); | ||
} | ||
|
||
[Fact] | ||
public void ElectricCurrentDividedByTimeSpanEqualsElectricCurrentGradient() | ||
{ | ||
ElectricCurrentGradient electricCurrentGradient = ElectricCurrent.FromAmperes(10) / TimeSpan.FromSeconds(2); | ||
Assert.Equal(ElectricCurrentGradient.FromAmperesPerSecond(5), electricCurrentGradient); | ||
} | ||
} | ||
} |
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,12 +1,16 @@ | ||
// 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; | ||
|
||
using Xunit; | ||
|
||
namespace UnitsNet.Tests | ||
{ | ||
public class PressureChangeRateTests : PressureChangeRateTestsBase | ||
{ | ||
protected override bool SupportsSIUnitSystem => false; | ||
protected override double AtmospheresPerSecondInOnePascalPerSecond => 9.8692*1E-6; | ||
protected override double AtmospheresPerSecondInOnePascalPerSecond => 9.8692 * 1E-6; | ||
|
||
protected override double KilopascalsPerSecondInOnePascalPerSecond => 1e-3; | ||
|
||
|
@@ -41,5 +45,19 @@ public class PressureChangeRateTests : PressureChangeRateTestsBase | |
protected override double MillibarsPerMinuteInOnePascalPerSecond => 0.6; | ||
|
||
protected override double MillibarsPerSecondInOnePascalPerSecond => 1e-2; | ||
|
||
[Fact] | ||
public void PressureChangeRateTimesDurationEqualsPressure() | ||
{ | ||
Pressure pressure = PressureChangeRate.FromPascalsPerSecond(500) * Duration.FromSeconds(2); | ||
Assert.Equal(Pressure.FromPascals(1000), pressure); | ||
} | ||
|
||
[Fact] | ||
public void PressureChangeRateTimesTimeSpanEqualsPressure() | ||
{ | ||
Pressure pressure = PressureChangeRate.FromPascalsPerSecond(500) * TimeSpan.FromSeconds(2); | ||
Assert.Equal(Pressure.FromPascals(1000), pressure); | ||
} | ||
} | ||
} |
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,6 +1,8 @@ | ||
// 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; | ||
|
||
namespace UnitsNet | ||
{ | ||
public partial struct ElectricCurrent | ||
|
@@ -24,5 +26,17 @@ public partial struct ElectricCurrent | |
{ | ||
return ElectricCharge.FromAmpereHours(current.Amperes * time.Hours); | ||
} | ||
|
||
/// <summary>Get <see cref="ElectricCurrentGradient"/> from <see cref="ElectricCurrent"/> divided by <see cref="Duration"/>.</summary> | ||
public static ElectricCurrentGradient operator /(ElectricCurrent current, Duration duration) | ||
{ | ||
return ElectricCurrentGradient.FromAmperesPerSecond(current.Amperes / duration.Seconds); | ||
} | ||
|
||
/// <summary>Get <see cref="ElectricCurrentGradient"/> from <see cref="ElectricCurrent"/> divided by <see cref="TimeSpan"/>.</summary> | ||
public static ElectricCurrentGradient operator /(ElectricCurrent current, TimeSpan timeSpan) | ||
{ | ||
return ElectricCurrentGradient.FromAmperesPerSecond(current.Amperes / timeSpan.TotalSeconds); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
UnitsNet/CustomCode/Quantities/ElectricCurrentGradient.extra.cs
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// 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; | ||
|
||
namespace UnitsNet | ||
{ | ||
public partial struct ElectricCurrentGradient | ||
{ | ||
/// <summary>Get <see cref="ElectricCurrent"/> from <see cref="ElectricCurrentGradient"/> times <see cref="Duration"/>.</summary> | ||
public static ElectricCurrent operator *(ElectricCurrentGradient currentGradient, Duration duration) | ||
{ | ||
return ElectricCurrent.FromAmperes(currentGradient.AmperesPerSecond * duration.Seconds); | ||
} | ||
|
||
/// <summary>Get <see cref="ElectricCurrent"/> from <see cref="ElectricCurrentGradient"/> times <see cref="TimeSpan"/>.</summary> | ||
public static ElectricCurrent operator *(ElectricCurrentGradient currentGradient, TimeSpan timeSpan) | ||
{ | ||
return ElectricCurrent.FromAmperes(currentGradient.AmperesPerSecond * timeSpan.TotalSeconds); | ||
} | ||
} | ||
} |
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,6 +1,8 @@ | ||
// 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; | ||
|
||
namespace UnitsNet | ||
{ | ||
public partial struct Pressure | ||
|
@@ -40,5 +42,17 @@ public partial struct Pressure | |
{ | ||
return new Force(pressure.Pascals / reciprocalArea.InverseSquareMeters, UnitsNet.Units.ForceUnit.Newton); | ||
} | ||
|
||
/// <summary>Get <see cref="PressureChangeRate"/> from <see cref="Pressure"/> divided by <see cref="TimeSpan"/> </summary> | ||
public static PressureChangeRate operator /(Pressure pressure, TimeSpan timeSpan) | ||
{ | ||
return new PressureChangeRate(pressure.Pascals / timeSpan.TotalSeconds , UnitsNet.Units.PressureChangeRateUnit.PascalPerSecond); | ||
} | ||
|
||
/// <summary>Get <see cref="PressureChangeRate"/> from <see cref="Pressure"/> divided by <see cref="Duration"/> </summary> | ||
public static PressureChangeRate operator /(Pressure pressure, Duration duration) | ||
{ | ||
return new PressureChangeRate(pressure.Pascals / duration.Seconds, UnitsNet.Units.PressureChangeRateUnit.PascalPerSecond); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
UnitsNet/CustomCode/Quantities/PressureChangeRate.extra.cs
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// 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; | ||
|
||
namespace UnitsNet | ||
{ | ||
public partial struct PressureChangeRate | ||
{ | ||
/// <summary>Get <see cref="Pressure"/> from <see cref="PressureChangeRate"/> times <see cref="TimeSpan"/> </summary> | ||
public static Pressure operator *(PressureChangeRate pressureChangeRate, TimeSpan timeSpan) | ||
{ | ||
return new Pressure(pressureChangeRate.PascalsPerSecond * timeSpan.TotalSeconds , UnitsNet.Units.PressureUnit.Pascal); | ||
} | ||
|
||
/// <summary>Get <see cref="Pressure"/> from <see cref="PressureChangeRate"/> times <see cref="Duration"/> </summary> | ||
public static Pressure operator *(PressureChangeRate pressureChangeRate, Duration duration) | ||
{ | ||
return new Pressure(pressureChangeRate.PascalsPerSecond * duration.Seconds, UnitsNet.Units.PressureUnit.Pascal); | ||
} | ||
} | ||
} |