File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
src/Synercoding.Primitives
tests/Synercoding.Primitives.Tests Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -216,6 +216,15 @@ public bool Equals(UnitValue other)
216
216
public static UnitValue operator * ( UnitValue a , double b )
217
217
=> new UnitValue ( a . Value * b , a . Unit ) ;
218
218
219
+ /// <summary>
220
+ /// Multiply a given <see cref="UnitValue"/> by a <see cref="double"/>
221
+ /// </summary>
222
+ /// <param name="a">The <see cref="UnitValue"/> to multiply</param>
223
+ /// <param name="b">The <see cref="double"/> to multiply by</param>
224
+ /// <returns>The result of the multiplication operation</returns>
225
+ public static UnitValue operator * ( double a , UnitValue b )
226
+ => new UnitValue ( b . Value * a , b . Unit ) ;
227
+
219
228
/// <summary>
220
229
/// Divide a given <see cref="UnitValue"/> by another <see cref="UnitValue"/>
221
230
/// </summary>
Original file line number Diff line number Diff line change @@ -139,5 +139,39 @@ public void FromDesignation_WithPixels_ThrowsArgumentException()
139
139
140
140
Assert . Throws < ArgumentException > ( ( ) => Unit . FromDesignation ( designation ) ) ;
141
141
}
142
+
143
+ [ Fact ]
144
+ public void MultiplicationOperator_WithLeftDouble_IsUnitValue ( )
145
+ {
146
+ // Arrange
147
+ var left = 2d ;
148
+ var right = new UnitValue ( 5 , Unit . Millimeters ) ;
149
+ var expected = new UnitValue ( 10 , Unit . Millimeters ) ;
150
+
151
+ // Act
152
+ var result = left * right ;
153
+
154
+ // Assert
155
+ Assert . Equal ( expected , result ) ;
156
+ Assert . Equal ( expected . Value , result . Value ) ;
157
+ Assert . Equal ( expected . Unit , result . Unit ) ;
158
+ }
159
+
160
+ [ Fact ]
161
+ public void MultiplicationOperator_WithRightDouble_IsUnitValue ( )
162
+ {
163
+ // Arrange
164
+ var left = new UnitValue ( 5 , Unit . Millimeters ) ;
165
+ var right = 2d ;
166
+ var expected = new UnitValue ( 10 , Unit . Millimeters ) ;
167
+
168
+ // Act
169
+ var result = left * right ;
170
+
171
+ // Assert
172
+ Assert . Equal ( expected , result ) ;
173
+ Assert . Equal ( expected . Value , result . Value ) ;
174
+ Assert . Equal ( expected . Unit , result . Unit ) ;
175
+ }
142
176
}
143
177
}
You can’t perform that action at this time.
0 commit comments