Skip to content

Commit 97e53e7

Browse files
authored
Merge pull request #25 from synercoder/develop
Fix default value of unitdesignation
2 parents eb6db27 + b08eea7 commit 97e53e7

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

src/Synercoding.Primitives/PackageDetails.props

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +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> - Added extra default UnitDesignation to indicate a value is not properly initialized.
14-
- Removed support for .NET 4.5.2 &amp; .NET Core 2.1
15-
- Added support for .NET 4.8 &amp; .NET 6.0
16-
- Improved XML docs.
17-
- Added extra constructor to Spacing
18-
- Added Pixels to ValueCreator
19-
- Added Parse and TryParse methods to: Unit &amp; Value</PackageReleaseNotes>
13+
<PackageReleaseNotes> - Fix default value of unitdesignation</PackageReleaseNotes>
2014
</PropertyGroup>
2115

2216
</Project>

src/Synercoding.Primitives/UnitDesignation.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ public enum UnitDesignation : byte
88
/// <summary>
99
/// Points, 72 per inch
1010
/// </summary>
11-
Points,
11+
Points = 1,
1212
/// <summary>
1313
/// Millimeters, 25.4 per inch
1414
/// </summary>
15-
Millimeters,
15+
Millimeters = 2,
1616
/// <summary>
1717
/// Centimeters, 2.54 per inch
1818
/// </summary>
19-
Centimeters,
19+
Centimeters = 3,
2020
/// <summary>
2121
/// Pixels, dependent on DPI
2222
/// </summary>
23-
Pixels,
23+
Pixels = 4,
2424
/// <summary>
2525
/// Inches
2626
/// </summary>
27-
Inches
27+
Inches = 5
2828
}

src/Synercoding.Primitives/Value.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public Value(double value, Unit unit)
3737
/// <inheritdoc />
3838
public Value ConvertTo(Unit unit)
3939
{
40-
if ((byte)unit.Designation == 0)
40+
if (unit.Designation == 0)
4141
throw new ArgumentException("The provided unit was not initialized.", nameof(unit));
4242

4343
if (Unit == unit)

tests/Synercoding.Primitives.Tests/UnitDesignationTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,17 @@ public void Shortform_AllEnums_HaveShortform()
2020
// Assert
2121
// No NotImplementedException thrown! Jeej
2222
}
23+
24+
[Fact]
25+
public void DefaultValueIsNotDefined()
26+
{
27+
// Arrange
28+
UnitDesignation value = 0;
29+
30+
// Act
31+
var result = Enum.IsDefined(value);
32+
33+
// Assert
34+
Assert.False(result);
35+
}
2336
}

0 commit comments

Comments
 (0)