File tree Expand file tree Collapse file tree 4 files changed +39
-0
lines changed
UnitsNet.Tests/CustomCode
UnitsNet/CustomCode/Quantities Expand file tree Collapse file tree 4 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -63,5 +63,12 @@ public void LinearDensityDividedByDensityEqualsArea()
63
63
Area area = LinearDensity . FromGramsPerCentimeter ( 10 ) / Density . FromGramsPerCubicCentimeter ( 2 ) ;
64
64
Assert . Equal ( 5 , area . SquareCentimeters ) ;
65
65
}
66
+
67
+ [ Fact ]
68
+ public void LinearDensityTimesLengthEqualsMass ( )
69
+ {
70
+ Mass mass = LinearDensity . FromGramsPerCentimeter ( 10 ) * Length . FromCentimeters ( 2 ) ;
71
+ Assert . Equal ( 20 , mass . Grams ) ;
72
+ }
66
73
}
67
74
}
Original file line number Diff line number Diff line change @@ -118,6 +118,20 @@ public void MassTimesAccelerationEqualsForce()
118
118
Assert . Equal ( force , Force . FromNewtons ( 54 ) ) ;
119
119
}
120
120
121
+ [ Fact ]
122
+ public void MassDividedByLengthEqualsLinearDensity ( )
123
+ {
124
+ LinearDensity linearDensity = Mass . FromKilograms ( 18 ) / Length . FromMeters ( 3 ) ;
125
+ Assert . Equal ( linearDensity , LinearDensity . FromKilogramsPerMeter ( 6 ) ) ;
126
+ }
127
+
128
+ [ Fact ]
129
+ public void MassDividedByLinearDensityEqualsLength ( )
130
+ {
131
+ Length length = Mass . FromKilograms ( 18 ) / LinearDensity . FromKilogramsPerMeter ( 3 ) ;
132
+ Assert . Equal ( length , Length . FromMeters ( 6 ) ) ;
133
+ }
134
+
121
135
[ Fact ]
122
136
public void NegativeMassToStonePoundsReturnsCorrectValues ( )
123
137
{
Original file line number Diff line number Diff line change @@ -17,5 +17,11 @@ public partial struct LinearDensity
17
17
{
18
18
return Area . FromSquareMeters ( linearDensity . KilogramsPerMeter / density . KilogramsPerCubicMeter ) ;
19
19
}
20
+
21
+ /// <summary>Get <see cref="Mass"/> from <see cref="LinearDensity"/> times <see cref="Length"/>.</summary>
22
+ public static Mass operator * ( LinearDensity linearDensity , Length length )
23
+ {
24
+ return Mass . FromKilograms ( linearDensity . KilogramsPerMeter * length . Meters ) ;
25
+ }
20
26
}
21
27
}
Original file line number Diff line number Diff line change @@ -99,6 +99,18 @@ public static Mass FromStonePounds(double stone, double pounds)
99
99
{
100
100
return Force . FromNewtons ( mass . Kilograms * acceleration . MetersPerSecondSquared ) ;
101
101
}
102
+
103
+ /// <summary>Get <see cref="LinearDensity"/> from <see cref="Mass"/> times <see cref="Length"/>.</summary>
104
+ public static LinearDensity operator / ( Mass mass , Length length )
105
+ {
106
+ return LinearDensity . FromKilogramsPerMeter ( mass . Kilograms / length . Meters ) ;
107
+ }
108
+
109
+ /// <summary>Get <see cref="Length"/> from <see cref="Mass"/> divided by <see cref="LinearDensity"/>.</summary>
110
+ public static Length operator / ( Mass mass , LinearDensity linearDensity )
111
+ {
112
+ return Length . FromMeters ( mass . Kilograms / linearDensity . KilogramsPerMeter ) ;
113
+ }
102
114
}
103
115
104
116
/// <summary>
You can’t perform that action at this time.
0 commit comments