diff --git a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileId.cs b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileId.cs index 67911936f..138999710 100644 --- a/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileId.cs +++ b/src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileId.cs @@ -13,7 +13,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// /// A profile ID with all values set to zero /// - public static readonly IccProfileId Zero = new IccProfileId(0, 0, 0, 0); + public static readonly IccProfileId Zero = default; /// /// Initializes a new instance of the struct. @@ -53,16 +53,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc /// /// Gets a value indicating whether the ID is set or just consists of zeros /// - public bool IsSet - { - get - { - return this.Part1 != 0 - && this.Part2 != 0 - && this.Part3 != 0 - && this.Part4 != 0; - } - } + public bool IsSet => !this.Equals(Zero); /// /// Compares two objects for equality. @@ -131,4 +122,4 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc return value.ToString("X").PadLeft(8, '0'); } } -} +} \ No newline at end of file diff --git a/tests/ImageSharp.Tests/MetaData/Profiles/ICC/Various/IccProfileIdTests.cs b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/Various/IccProfileIdTests.cs new file mode 100644 index 000000000..46b8b31b4 --- /dev/null +++ b/tests/ImageSharp.Tests/MetaData/Profiles/ICC/Various/IccProfileIdTests.cs @@ -0,0 +1,32 @@ +// Copyright (c) Six Labors and contributors. +// Licensed under the Apache License, Version 2.0. + +using SixLabors.ImageSharp.MetaData.Profiles.Icc; +using Xunit; + +namespace SixLabors.ImageSharp.Tests.Icc +{ + public class IccProfileIdTests + { + [Fact] + public void ZeroIsEqualToDefault() + { + Assert.True(IccProfileId.Zero.Equals(default)); + + Assert.False(default(IccProfileId).IsSet); + } + + [Fact] + public void SetIsTrueWhenNonDefaultValue() + { + var id = new IccProfileId(1, 2, 3, 4); + + Assert.True(id.IsSet); + + Assert.Equal(1u, id.Part1); + Assert.Equal(2u, id.Part2); + Assert.Equal(3u, id.Part3); + Assert.Equal(4u, id.Part4); + } + } +} \ No newline at end of file