File tree Expand file tree Collapse file tree 4 files changed +30
-0
lines changed
UnitsNet.Tests/CustomCode
UnitsNet/CustomCode/Quantities Expand file tree Collapse file tree 4 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -43,5 +43,12 @@ public void AccelerationTimesDensityEqualsSpecificWeight()
43
43
SpecificWeight specificWeight = Acceleration . FromMetersPerSecondSquared ( 10 ) * Density . FromKilogramsPerCubicMeter ( 2 ) ;
44
44
Assert . Equal ( SpecificWeight . FromNewtonsPerCubicMeter ( 20 ) , specificWeight ) ;
45
45
}
46
+
47
+ [ Fact ]
48
+ public void AccelerationTimesDuration ( )
49
+ {
50
+ Speed speed = Acceleration . FromMetersPerSecondSquared ( 10 ) * Duration . FromSeconds ( 10 ) ;
51
+ Assert . Equal ( Speed . FromMetersPerSecond ( 100 ) , speed ) ;
52
+ }
46
53
}
47
54
}
Original file line number Diff line number Diff line change @@ -192,5 +192,12 @@ public void DurationMultipliedByElectricCurrentEqualsElectricCharge()
192
192
ElectricCharge ah = Duration . FromHours ( 5 ) * ElectricCurrent . FromAmperes ( 4 ) ;
193
193
Assert . Equal ( 20 , ah . AmpereHours ) ;
194
194
}
195
+
196
+ [ Fact ]
197
+ public void DurationTimesAcceleration ( )
198
+ {
199
+ Speed speed = Duration . FromSeconds ( 10 ) * Acceleration . FromMetersPerSecondSquared ( 10 ) ;
200
+ Assert . Equal ( Speed . FromMetersPerSecond ( 100 ) , speed ) ;
201
+ }
195
202
}
196
203
}
Original file line number Diff line number Diff line change @@ -12,5 +12,13 @@ public partial struct Acceleration
12
12
{
13
13
return new SpecificWeight ( acceleration . MetersPerSecondSquared * density . KilogramsPerCubicMeter , UnitsNet . Units . SpecificWeightUnit . NewtonPerCubicMeter ) ;
14
14
}
15
+
16
+ /// <summary>
17
+ /// Multiply <see cref="Acceleration"/> and <see cref="Duration"/> to get <see cref="Speed"/>.
18
+ /// </summary>
19
+ public static Speed operator * ( Acceleration acceleration , Duration duration )
20
+ {
21
+ return new Speed ( acceleration . MetersPerSecondSquared * duration . Seconds , UnitsNet . Units . SpeedUnit . MeterPerSecond ) ;
22
+ }
15
23
}
16
24
}
Original file line number Diff line number Diff line change @@ -103,5 +103,13 @@ public static explicit operator Duration(TimeSpan duration)
103
103
{
104
104
return ElectricCharge . FromAmpereHours ( current . Amperes * time . Hours ) ;
105
105
}
106
+
107
+ /// <summary>
108
+ /// Multiply <see cref="Duration"/> and <see cref="Acceleration"/> to get <see cref="Speed"/>.
109
+ /// </summary>
110
+ public static Speed operator * ( Duration duration , Acceleration acceleration )
111
+ {
112
+ return new Speed ( acceleration . MetersPerSecondSquared * duration . Seconds , UnitsNet . Units . SpeedUnit . MeterPerSecond ) ;
113
+ }
106
114
}
107
115
}
You can’t perform that action at this time.
0 commit comments