Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/Synercoding.Primitives/PackageDetails.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@
<Product>Synercoding.Primitives</Product>
<Title>Synercoding.Primitives</Title>
<Description>Primitives with units attached (think mm, cm, in, px) that can be used for 2D graphics.</Description>
<PackageReleaseNotes> - Added extra default UnitDesignation to indicate a value is not properly initialized.
- Removed support for .NET 4.5.2 &amp; .NET Core 2.1
- Added support for .NET 4.8 &amp; .NET 6.0
- Improved XML docs.
- Added extra constructor to Spacing
- Added Pixels to ValueCreator
- Added Parse and TryParse methods to: Unit &amp; Value</PackageReleaseNotes>
<PackageReleaseNotes> - Fix default value of unitdesignation</PackageReleaseNotes>
</PropertyGroup>

</Project>
10 changes: 5 additions & 5 deletions src/Synercoding.Primitives/UnitDesignation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ public enum UnitDesignation : byte
/// <summary>
/// Points, 72 per inch
/// </summary>
Points,
Points = 1,
/// <summary>
/// Millimeters, 25.4 per inch
/// </summary>
Millimeters,
Millimeters = 2,
/// <summary>
/// Centimeters, 2.54 per inch
/// </summary>
Centimeters,
Centimeters = 3,
/// <summary>
/// Pixels, dependent on DPI
/// </summary>
Pixels,
Pixels = 4,
/// <summary>
/// Inches
/// </summary>
Inches
Inches = 5
}
2 changes: 1 addition & 1 deletion src/Synercoding.Primitives/Value.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Value(double value, Unit unit)
/// <inheritdoc />
public Value ConvertTo(Unit unit)
{
if ((byte)unit.Designation == 0)
if (unit.Designation == 0)
throw new ArgumentException("The provided unit was not initialized.", nameof(unit));

if (Unit == unit)
Expand Down
13 changes: 13 additions & 0 deletions tests/Synercoding.Primitives.Tests/UnitDesignationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,17 @@ public void Shortform_AllEnums_HaveShortform()
// Assert
// No NotImplementedException thrown! Jeej
}

[Fact]
public void DefaultValueIsNotDefined()
{
// Arrange
UnitDesignation value = 0;

// Act
var result = Enum.IsDefined(value);

// Assert
Assert.False(result);
}
}