From 66e7e79561a90a9907681bb4ed92a4642fd921e4 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 20 Apr 2022 16:35:44 +0100 Subject: [PATCH] Rename Clusivity enum to InclusiveOptions https://sonarcloud.io/project/issues?fileUuids=AX9gUgFivY1Q2LeuiUva&pullRequest=43&id=oliverbooth_X10D&open=AX75E353Zn_cGN5aPZcQ --- X10D.Tests/src/Core/ComparableTests.cs | 14 +++++++------- .../ComparableExtensions/ComparableExtensions.cs | 9 +++++---- .../{Clusivity.cs => InclusiveOptions.cs} | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) rename X10D/src/ComparableExtensions/{Clusivity.cs => InclusiveOptions.cs} (95%) diff --git a/X10D.Tests/src/Core/ComparableTests.cs b/X10D.Tests/src/Core/ComparableTests.cs index 72dadf6..95fab04 100644 --- a/X10D.Tests/src/Core/ComparableTests.cs +++ b/X10D.Tests/src/Core/ComparableTests.cs @@ -1,4 +1,4 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace X10D.Tests.Core { @@ -22,13 +22,13 @@ namespace X10D.Tests.Core Assert.IsFalse(lower.Between(value, upper), "lower.Between(value, upper)"); Assert.IsFalse(upper.Between(lower, value), "upper.Between(lower, value)"); - Assert.IsTrue(upper.Between(lower, upper, Clusivity.UpperInclusive), "upper.Between(lower, upper, Clusivity.UpperInclusive)"); - Assert.IsTrue(upper.Between(lower, upper, Clusivity.Inclusive), "upper.Between(lower, upper, Clusivity.Inclusive)"); - Assert.IsFalse(upper.Between(lower, upper, Clusivity.LowerInclusive), "upper.Between(lower, upper, Clusivity.LowerInclusive)"); + Assert.IsTrue(upper.Between(lower, upper, InclusiveOptions.UpperInclusive), "upper.Between(lower, upper, Clusivity.UpperInclusive)"); + Assert.IsTrue(upper.Between(lower, upper, InclusiveOptions.Inclusive), "upper.Between(lower, upper, Clusivity.Inclusive)"); + Assert.IsFalse(upper.Between(lower, upper, InclusiveOptions.LowerInclusive), "upper.Between(lower, upper, Clusivity.LowerInclusive)"); - Assert.IsTrue(lower.Between(lower, upper, Clusivity.LowerInclusive), "lower.Between(lower, upper, Clusivity.LowerInclusive)"); - Assert.IsTrue(lower.Between(lower, upper, Clusivity.Inclusive), "lower.Between(lower, upper, Clusivity.Inclusive)"); - Assert.IsFalse(lower.Between(lower, upper, Clusivity.UpperInclusive), "lower.Between(lower, upper, Clusivity.UpperInclusive)"); + Assert.IsTrue(lower.Between(lower, upper, InclusiveOptions.LowerInclusive), "lower.Between(lower, upper, Clusivity.LowerInclusive)"); + Assert.IsTrue(lower.Between(lower, upper, InclusiveOptions.Inclusive), "lower.Between(lower, upper, Clusivity.Inclusive)"); + Assert.IsFalse(lower.Between(lower, upper, InclusiveOptions.UpperInclusive), "lower.Between(lower, upper, Clusivity.UpperInclusive)"); } } } diff --git a/X10D/src/ComparableExtensions/ComparableExtensions.cs b/X10D/src/ComparableExtensions/ComparableExtensions.cs index b2c9098..a8c95ee 100644 --- a/X10D/src/ComparableExtensions/ComparableExtensions.cs +++ b/X10D/src/ComparableExtensions/ComparableExtensions.cs @@ -16,7 +16,7 @@ public static class ComparableExtensions /// The value to compare. /// The exclusive lower bound. /// The exclusive upper bound. - /// The comparison clusivity. + /// The comparison clusivity. /// /// if is between the and /// @@ -44,7 +44,8 @@ public static class ComparableExtensions /// // True /// /// - public static bool Between(this T1 value, T2 lower, T3 upper, Clusivity clusivity = Clusivity.None) + public static bool Between(this T1 value, T2 lower, T3 upper, + InclusiveOptions inclusiveOptions = InclusiveOptions.None) where T1 : IComparable, IComparable where T2 : IComparable where T3 : IComparable @@ -61,11 +62,11 @@ public static class ComparableExtensions nameof(lower)); } - bool lowerComparison = (clusivity & Clusivity.LowerInclusive) != 0 + bool lowerComparison = (inclusiveOptions & InclusiveOptions.LowerInclusive) != 0 ? value.CompareTo(lower) >= 0 : value.CompareTo(lower) > 0; - bool upperComparison = (clusivity & Clusivity.UpperInclusive) != 0 + bool upperComparison = (inclusiveOptions & InclusiveOptions.UpperInclusive) != 0 ? value.CompareTo(upper) <= 0 : value.CompareTo(upper) < 0; diff --git a/X10D/src/ComparableExtensions/Clusivity.cs b/X10D/src/ComparableExtensions/InclusiveOptions.cs similarity index 95% rename from X10D/src/ComparableExtensions/Clusivity.cs rename to X10D/src/ComparableExtensions/InclusiveOptions.cs index 9bac34e..9d86d46 100644 --- a/X10D/src/ComparableExtensions/Clusivity.cs +++ b/X10D/src/ComparableExtensions/InclusiveOptions.cs @@ -4,7 +4,7 @@ /// Provides options for clusivity. /// [Flags] -public enum Clusivity : byte +public enum InclusiveOptions : byte { /// /// Indicates that the comparison will be exclusive.