Skip to content

Commit d93764e

Browse files
authored
Merge pull request #19 from synercoder/features/release-rc06
Fixed value division by double
2 parents 0324d87 + a43d035 commit d93764e

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

src/Synercoding.Primitives/PackageDetails.props

+1-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
<Product>Synercoding.Primitives</Product>
1111
<Title>Synercoding.Primitives</Title>
1212
<Description>Primitives with units attached (think mm, cm, in, px) that can be used for 2D graphics.</Description>
13-
<PackageReleaseNotes>
14-
- Added support for net452 &amp; net5.0.
15-
- Added a ValueCreator class, supposed to be used as a static using.
16-
- Added AsRaw extensions for Point &amp; Size
17-
</PackageReleaseNotes>
13+
<PackageReleaseNotes> - Fixed value division by double</PackageReleaseNotes>
1814
</PropertyGroup>
1915

2016
</Project>

src/Synercoding.Primitives/Value.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public bool Equals(Value other)
241241
/// <param name="a">The <see cref="Value"/> to divide</param>
242242
/// <param name="b">The <see cref="double"/> to divisor</param>
243243
/// <returns>The result of the division operation</returns>
244-
public static double operator /(Value a, double b)
245-
=> a.Raw / b;
244+
public static Value operator /(Value a, double b)
245+
=> new Value(a.Raw / b, a.Unit);
246246
}
247247
}

tests/Synercoding.Primitives.Tests/ValueTests.cs

+15
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,21 @@ public void DivisionOperator_1cmAnd1mm_containes10times()
120120
Assert.Equal(expected, result);
121121
}
122122

123+
[Fact]
124+
public void DivisionOperator_1cmAnd2_Is0dot5cm()
125+
{
126+
// Arrange
127+
var cm = new Value(1, Unit.Centimeters);
128+
var amount = 2;
129+
var expected = new Value(0.5, Unit.Centimeters);
130+
131+
// Act
132+
var result = cm / amount;
133+
134+
// Assert
135+
Assert.Equal(expected, result);
136+
}
137+
123138
[Fact]
124139
public void FromDesignation_AllEnumValuesExceptPx_DoesNotThrowNotImplementedException()
125140
{

0 commit comments

Comments
 (0)