Skip to content

Commit

Permalink
Add new ctor for SkinSection
Browse files Browse the repository at this point in the history
  • Loading branch information
PotatoMaster101 committed Apr 2, 2023
1 parent 41957dc commit 069f173
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/McSkin/McSkin.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<AssemblyVersion>1.0.1</AssemblyVersion>
<AssemblyVersion>1.0.2</AssemblyVersion>
<Authors>PotatoMaster101</Authors>
<Copyright>Copyright (c) 2023 PotatoMaster101</Copyright>
<Description>Small library for playing with Minecraft Skins</Description>
<FileVersion>1.0.1</FileVersion>
<FileVersion>1.0.2</FileVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReleaseNotes>- Added missing `ConfigureAwait`
- Added `isLegacy` to `Skin` constructor</PackageReleaseNotes>
<PackageReleaseNotes>- Added new `SkinSection` ctor taking `Rectangle`</PackageReleaseNotes>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageTags>Minecraft</PackageTags>
<RepositoryUrl>https://github.com/PotatoMaster101/McSkin</RepositoryUrl>
<TargetFramework>net7.0</TargetFramework>
<Title>McSkin</Title>
<Version>1.0.1</Version>
<Version>1.0.2</Version>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand Down
9 changes: 9 additions & 0 deletions src/McSkin/SkinSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ public class SkinSection
/// </summary>
public Point Point => new(X, Y);

/// <summary>
/// Constructs a new instance of <see cref="SkinSection"/>.
/// </summary>
/// <param name="rect">The rectangle containing the position and size.</param>
/// <param name="legacyEquivalent">The equivalent section that can be used on legacy skins.</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown when any argument is out of range.</exception>
public SkinSection(Rectangle rect, SkinSection? legacyEquivalent = null)
: this(rect.X, rect.Y, rect.Width, rect.Height, legacyEquivalent) { }

/// <summary>
/// Constructs a new instance of <see cref="SkinSection"/>.
/// </summary>
Expand Down
28 changes: 25 additions & 3 deletions test/McSkin.Test/SkinSectionTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Xunit;
using SixLabors.ImageSharp;
using Xunit;

namespace McSkin.Test;

Expand All @@ -12,7 +13,28 @@ public class SkinSectionTest
[InlineData(0, 0, Skin.StandardWidth, Skin.LegacyHeight)]
[InlineData(32, 32, 32, 32)]
[InlineData(0, 0, 1, 1)]
public void Constructor_SetsMember(int x, int y, int width, int height)
public void Constructor1_SetsMember(int x, int y, int width, int height)
{
// arrange
var rect = new Rectangle(x, y, width, height);

// act
var section = new SkinSection(rect);

// assert
Assert.Equal(x, section.X);
Assert.Equal(y, section.Y);
Assert.Equal(width, section.Width);
Assert.Equal(height, section.Height);
Assert.Null(section.LegacyEquivalentSection);
}

[Theory]
[InlineData(0, 0, Skin.StandardWidth, Skin.StandardHeight)]
[InlineData(0, 0, Skin.StandardWidth, Skin.LegacyHeight)]
[InlineData(32, 32, 32, 32)]
[InlineData(0, 0, 1, 1)]
public void Constructor2_SetsMember(int x, int y, int width, int height)
{
// act
var section = new SkinSection(x, y, width, height);
Expand All @@ -35,7 +57,7 @@ public void Constructor_SetsMember(int x, int y, int width, int height)
[InlineData(-1, 0, 1, 1)]
[InlineData(0, -1, 1, 1)]
[InlineData(0, 0, 0, 0)]
public void Constructor_ThrowsOnOutOfRange(int x, int y, int width, int height)
public void Constructor2_ThrowsOnOutOfRange(int x, int y, int width, int height)
{
// assert
Assert.Throws<ArgumentOutOfRangeException>(() => new SkinSection(x, y, width, height));
Expand Down

0 comments on commit 069f173

Please sign in to comment.