diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index b36e6116..baba1f61 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -59,6 +59,11 @@ jobs: with: dotnet-version: 6.x + - name: Setup .NET 8.x + uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4 + with: + dotnet-version: 8.x + # Caching Tools - name: Cache Tools uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1 diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml index 1034a531..9f1d54c6 100644 --- a/.github/workflows/pr-build.yml +++ b/.github/workflows/pr-build.yml @@ -43,7 +43,12 @@ jobs: with: dotnet-version: 6.x - # Caching Tools + - name: Setup .NET 8.x + uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4 + with: + dotnet-version: 8.x + + # Caching Tools - name: Cache Tools uses: actions/cache@ab5e6d0c87105b4c9c2047343972218f562e4319 # v4.0.1 with: diff --git a/src/oehen.arguard.Tests/ArgumentEmtpyGuardTest.cs b/src/oehen.arguard.Tests/ArgumentEmtpyGuardTest.cs index 781fd537..b9e62637 100644 --- a/src/oehen.arguard.Tests/ArgumentEmtpyGuardTest.cs +++ b/src/oehen.arguard.Tests/ArgumentEmtpyGuardTest.cs @@ -1,62 +1,81 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace oehen.arguard -{ - [UseCulture("en-US")] - public class ArgumentEmtpyGuardTest - { - [Fact] - public void ThrowIfIsNullOrEmpty_ShouldThrowArgumentNullException_If_StringArgumentIsNullOrEmpty() - { - const string argument = ""; - var exception = Assert.Throws(() => - { - // ReSharper disable once ExpressionIsAlwaysNull - argument.ThrowIfIsNullOrEmpty(nameof(argument)); - }); - exception.Message.Should().Be("Argument is null or empty. (Parameter 'argument')"); - } - - [Fact] - public void ThrowIfIsNullOrEmpty_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsStringValue() - { - const string argument = "not empty value"; - var exception = Record.Exception(() => { argument.ThrowIfIsNullOrEmpty(nameof(argument)); }); - Assert.Null(exception); - } - - [Fact] - public void ThrowIfIsNullOrWhiteSpace_ShouldThrowArgumentNullException_If_StringArgumentIsNull() - { - string argument = null; - var exception = Assert.Throws(() => - { - // ReSharper disable once ExpressionIsAlwaysNull - argument.ThrowIfIsNullOrWhiteSpace(nameof(argument)); - }); - exception.Message.Should().Be("Argument is null or whitespace. (Parameter 'argument')"); - } - - [Fact] - public void ThrowIfIsNullOrWhiteSpace_ShouldThrowArgumentNullException_If_StringArgumentIsWhiteSpace() - { - const string argument = " "; - var exception = Assert.Throws(() => - { - // ReSharper disable once ExpressionIsAlwaysNull - argument.ThrowIfIsNullOrWhiteSpace(nameof(argument)); - }); - exception.Message.Should().Be("Argument is null or whitespace. (Parameter 'argument')"); - } - - [Fact] - public void ThrowIfIsNullOrWhiteSpace_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsStringValue() - { - const string argument = "Hello"; - var exception = Record.Exception(() => { argument.ThrowIfIsNullOrWhiteSpace(nameof(argument)); }); - Assert.Null(exception); - } - } +using System; +using FluentAssertions; +using Xunit; + +namespace oehen.arguard +{ + [UseCulture("en-US")] + public class ArgumentEmtpyGuardTest + { + [Fact] + public void ThrowIfIsNullOrEmpty_ShouldThrowArgumentNullException_If_StringArgumentIsNullOrEmpty() + { + const string argument = ""; + var exception = Assert.Throws(() => + { + // ReSharper disable once ExpressionIsAlwaysNull + argument.ThrowIfIsNullOrEmpty(nameof(argument)); + }); + +#if NET472 +#elif NET48 + exception.Message.Should().Be("Argument is null or empty.\r\nParameter name: argument"); +#else + exception.Message.Should().Be("Argument is null or empty. (Parameter 'argument')"); +#endif + } + + [Fact] + public void ThrowIfIsNullOrEmpty_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsStringValue() + { + const string argument = "not empty value"; + var exception = Record.Exception(() => { argument.ThrowIfIsNullOrEmpty(nameof(argument)); }); + Assert.Null(exception); + } + + [Fact] + public void ThrowIfIsNullOrWhiteSpace_ShouldThrowArgumentNullException_If_StringArgumentIsNull() + { + string argument = null; + var exception = Assert.Throws(() => + { + // ReSharper disable once ExpressionIsAlwaysNull + argument.ThrowIfIsNullOrWhiteSpace(nameof(argument)); + }); + +#if NET472 +#elif NET48 + exception.Message.Should().Be("Argument is null or whitespace.\r\nParameter name: argument"); +#else + exception.Message.Should().Be("Argument is null or whitespace. (Parameter 'argument')"); +#endif + + } + + [Fact] + public void ThrowIfIsNullOrWhiteSpace_ShouldThrowArgumentNullException_If_StringArgumentIsWhiteSpace() + { + const string argument = " "; + var exception = Assert.Throws(() => + { + // ReSharper disable once ExpressionIsAlwaysNull + argument.ThrowIfIsNullOrWhiteSpace(nameof(argument)); + }); + +#if NET472 +#elif NET48 + exception.Message.Should().Be("Argument is null or whitespace.\r\nParameter name: argument"); +#else + exception.Message.Should().Be("Argument is null or whitespace. (Parameter 'argument')"); +#endif + } + + [Fact] + public void ThrowIfIsNullOrWhiteSpace_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsStringValue() + { + const string argument = "Hello"; + var exception = Record.Exception(() => { argument.ThrowIfIsNullOrWhiteSpace(nameof(argument)); }); + Assert.Null(exception); + } + } } \ No newline at end of file diff --git a/src/oehen.arguard.Tests/ArgumentEnumerableGuardTest.cs b/src/oehen.arguard.Tests/ArgumentEnumerableGuardTest.cs index fd476a44..2fc4eed3 100644 --- a/src/oehen.arguard.Tests/ArgumentEnumerableGuardTest.cs +++ b/src/oehen.arguard.Tests/ArgumentEnumerableGuardTest.cs @@ -1,70 +1,75 @@ -using System; -using System.Collections.Generic; -using FluentAssertions; -using Xunit; - -namespace oehen.arguard -{ - [UseCulture("en-US")] - public class ArgumentEnumerableGuardTest - { - [Fact] - public void ThrowArgumentNullException_If_IEnumerableIsEmpty() - { - IEnumerable argument = new List(); - var exception = Assert.Throws(() => - { - argument.ThrowIfIsNullOrEmpty(nameof(argument)); - }); - exception.Message.Should().Be("Argument is null or empty. (Parameter 'argument')"); - } - - [Fact] - public void ThrowIfIsNullOrEmpty_When_IEnumerable_Has_One_Entry_Should_Not_Throw_ArgumentException() - { - IEnumerable argument = new List - { - "entry one" - }; - var exception = Record.Exception(() => { argument.ThrowIfIsNullOrEmpty(nameof(argument)); }); - Assert.Null(exception); - } - - [Fact] - public void ThrowIfIsNullOrEmpty_When_IEnumerable_Has_One_Entry_Should_Return_ArgumentValue() - { - IEnumerable argument = new List - { - "entry one" - }; - var result = argument.ThrowIfIsNullOrEmpty(nameof(argument)); - result.Should().BeEquivalentTo(argument); - } - - [Fact] - public void ThrowIfIsNullOrEmpty_When_IEnumerable_Has_Many_Entries_Should_Not_Throw_ArgumentException() - { - IEnumerable argument = new List - { - "entry one", - "entry two", - "entry three" - }; - var exception = Record.Exception(() => { argument.ThrowIfIsNullOrEmpty(nameof(argument)); }); - Assert.Null(exception); - } - - [Fact] - public void ThrowIfIsNullOrEmpty_When_IEnumerable_Has_Many_Entries_Should_Return_ArgumentValue() - { - IEnumerable argument = new List - { - "entry one", - "entry two", - "entry three" - }; - var result = argument.ThrowIfIsNullOrEmpty(nameof(argument)); - result.Should().BeEquivalentTo(argument); - } - } +using System; +using System.Collections.Generic; +using FluentAssertions; +using Xunit; + +namespace oehen.arguard +{ + [UseCulture("en-US")] + public class ArgumentEnumerableGuardTest + { + [Fact] + public void ThrowArgumentNullException_If_IEnumerableIsEmpty() + { + IEnumerable argument = new List(); + var exception = Assert.Throws(() => + { + argument.ThrowIfIsNullOrEmpty(nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be("Argument is null or empty.\r\nParameter name: argument"); +#else + exception.Message.Should().Be("Argument is null or empty. (Parameter 'argument')"); +#endif + } + + [Fact] + public void ThrowIfIsNullOrEmpty_When_IEnumerable_Has_One_Entry_Should_Not_Throw_ArgumentException() + { + IEnumerable argument = new List + { + "entry one" + }; + var exception = Record.Exception(() => { argument.ThrowIfIsNullOrEmpty(nameof(argument)); }); + Assert.Null(exception); + } + + [Fact] + public void ThrowIfIsNullOrEmpty_When_IEnumerable_Has_One_Entry_Should_Return_ArgumentValue() + { + IEnumerable argument = new List + { + "entry one" + }; + var result = argument.ThrowIfIsNullOrEmpty(nameof(argument)); + result.Should().BeEquivalentTo(argument); + } + + [Fact] + public void ThrowIfIsNullOrEmpty_When_IEnumerable_Has_Many_Entries_Should_Not_Throw_ArgumentException() + { + IEnumerable argument = new List + { + "entry one", + "entry two", + "entry three" + }; + var exception = Record.Exception(() => { argument.ThrowIfIsNullOrEmpty(nameof(argument)); }); + Assert.Null(exception); + } + + [Fact] + public void ThrowIfIsNullOrEmpty_When_IEnumerable_Has_Many_Entries_Should_Return_ArgumentValue() + { + IEnumerable argument = new List + { + "entry one", + "entry two", + "entry three" + }; + var result = argument.ThrowIfIsNullOrEmpty(nameof(argument)); + result.Should().BeEquivalentTo(argument); + } + } } \ No newline at end of file diff --git a/src/oehen.arguard.Tests/ArgumentNullGuardTest.cs b/src/oehen.arguard.Tests/ArgumentNullGuardTest.cs index ba07d719..0d239b30 100644 --- a/src/oehen.arguard.Tests/ArgumentNullGuardTest.cs +++ b/src/oehen.arguard.Tests/ArgumentNullGuardTest.cs @@ -1,95 +1,115 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace oehen.arguard -{ - public class ArgumentNullGuardTest - { - enum TestEnum - { - None, - Gruen, - Blau - } - - [Fact] - public void ThrowArgumentNullException_If_Enum_Is_Default() - { - TestEnum argument = default(TestEnum); - - // ReSharper disable once ExpressionIsAlwaysNull - var result = argument.ThrowIfNull(nameof(argument)); - - result.Should().Be(argument); - } - - [Fact] - public void ThrowArgumentNullException_If_Nullable_Enum_Is_Default() - { - TestEnum? argument = default(TestEnum); - - // ReSharper disable once ExpressionIsAlwaysNull - var result = argument.ThrowIfNull(nameof(argument)); - - result.Should().Be(argument); - } - - [Fact] - public void ThrowArgumentNullException_If_Nullable_Enum_Is_Null() - { - TestEnum? argument = null; - - var exception = Assert.Throws(() => - { - // ReSharper disable once ExpressionIsAlwaysNull - argument.ThrowIfNull(nameof(argument)); - }); - exception.Message.Should().Be("Value cannot be null. (Parameter 'argument')"); - } - - [Fact] - public void ThrowArgumentNullException_If_ObjectArgumentIsNull() - { - object argument = null; - var exception = Assert.Throws(() => - { - // ReSharper disable once ExpressionIsAlwaysNull - argument.ThrowIfNull(nameof(argument)); - }); - exception.Message.Should().Be("Value cannot be null. (Parameter 'argument')"); - } - - [Fact] - public void ThrowArgumentNullException_If_StringArgumentIsNull() - { - string argument = null; - var exception = Assert.Throws(() => - { - // ReSharper disable once ExpressionIsAlwaysNull - argument.ThrowIfNull(nameof(argument)); - }); - exception.Message.Should().Be("Value cannot be null. (Parameter 'argument')"); - } - - [Fact] - public void ThrowArgumentNullException_If_NullableIntArgumentIsNull() - { - int? argument = null; - var exception = Assert.Throws(() => - { - // ReSharper disable once ExpressionIsAlwaysNull - argument.ThrowIfNull(nameof(argument)); - }); - exception.Message.Should().Be("Value cannot be null. (Parameter 'argument')"); - } - - [Fact] - public void NotThrowIfIsLessOrEqualThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsNotNull() - { - const string argument = "Hello"; - var exception = Record.Exception(() => { argument.ThrowIfNull(nameof(argument)); }); - Assert.Null(exception); - } - } +using System; +using FluentAssertions; +using Xunit; + +namespace oehen.arguard +{ + public class ArgumentNullGuardTest + { + enum TestEnum + { + None, + Gruen, + Blau + } + + [Fact] + public void ThrowArgumentNullException_If_Enum_Is_Default() + { + TestEnum argument = default(TestEnum); + + // ReSharper disable once ExpressionIsAlwaysNull + var result = argument.ThrowIfNull(nameof(argument)); + + result.Should().Be(argument); + } + + [Fact] + public void ThrowArgumentNullException_If_Nullable_Enum_Is_Default() + { + TestEnum? argument = default(TestEnum); + + // ReSharper disable once ExpressionIsAlwaysNull + var result = argument.ThrowIfNull(nameof(argument)); + + result.Should().Be(argument); + } + + [Fact] + public void ThrowArgumentNullException_If_Nullable_Enum_Is_Null() + { + TestEnum? argument = null; + + var exception = Assert.Throws(() => + { + // ReSharper disable once ExpressionIsAlwaysNull + argument.ThrowIfNull(nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be("Value cannot be null.\r\nParameter name: argument"); +#else + exception.Message.Should().Be("Value cannot be null. (Parameter 'argument')"); +#endif + } + + [Fact] + public void ThrowArgumentNullException_If_ObjectArgumentIsNull() + { + object argument = null; + var exception = Assert.Throws(() => + { + // ReSharper disable once ExpressionIsAlwaysNull + argument.ThrowIfNull(nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be("Value cannot be null.\r\nParameter name: argument"); +#else + exception.Message.Should().Be("Value cannot be null. (Parameter 'argument')"); +#endif + } + + [Fact] + public void ThrowArgumentNullException_If_StringArgumentIsNull() + { + string argument = null; + var exception = Assert.Throws(() => + { + // ReSharper disable once ExpressionIsAlwaysNull + argument.ThrowIfNull(nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be("Value cannot be null.\r\nParameter name: argument"); +#else + exception.Message.Should().Be("Value cannot be null. (Parameter 'argument')"); +#endif + } + + [Fact] + public void ThrowArgumentNullException_If_NullableIntArgumentIsNull() + { + int? argument = null; + var exception = Assert.Throws(() => + { + // ReSharper disable once ExpressionIsAlwaysNull + argument.ThrowIfNull(nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be("Value cannot be null.\r\nParameter name: argument"); +#else + exception.Message.Should().Be("Value cannot be null. (Parameter 'argument')"); +#endif + } + + [Fact] + public void NotThrowIfIsLessOrEqualThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsNotNull() + { + const string argument = "Hello"; + var exception = Record.Exception(() => { argument.ThrowIfNull(nameof(argument)); }); + Assert.Null(exception); + } + } } \ No newline at end of file diff --git a/src/oehen.arguard.Tests/Between/ArgumentDecimalBetweenGuardTest.cs b/src/oehen.arguard.Tests/Between/ArgumentDecimalBetweenGuardTest.cs index 220c803b..f1e3c37a 100644 --- a/src/oehen.arguard.Tests/Between/ArgumentDecimalBetweenGuardTest.cs +++ b/src/oehen.arguard.Tests/Between/ArgumentDecimalBetweenGuardTest.cs @@ -1,40 +1,45 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace oehen.arguard.Between -{ - [UseCulture("en-US")] - public class ArgumentDecimalBetweenGuardTest - { - [Theory] - [InlineData(4, 3, 8)] - [InlineData(5, 3, 8)] - [InlineData(7, 3, 8)] - public void - Decimal_ThrowIfIsBetween_Should_Throw_Exception_When_Argument_Is_Between_Start_And_End_Value(decimal argument, decimal compareValueStart, decimal compareValueEnd) - { - var exception = Assert.Throws(() => - { - argument.ThrowIfIsBetween(compareValueStart, compareValueEnd, nameof(argument)); - }); - exception.Message.Should().Be($"Argument is between {compareValueStart} and {compareValueEnd}. (Parameter 'argument')" + - Environment.NewLine + $"Actual value was {argument}."); - } - - [Theory] - [InlineData(2, 3, 8)] - [InlineData(1, 3, 8)] - [InlineData(9, 3, 8)] - [InlineData(10, 3, 8)] - public void - Decimal_ThrowIfIsBetween_Should_Not_Throw_Exception_When_Argument_Is_Between_Start_And_End_Value(decimal argument, decimal compareValueStart, decimal compareValueEnd) - { - var exception = Record.Exception(() => - { - argument.ThrowIfIsBetween(compareValueStart, compareValueEnd, nameof(argument)); - }); - Assert.Null(exception); - } - } +using System; +using FluentAssertions; +using Xunit; + +namespace oehen.arguard.Between +{ + [UseCulture("en-US")] + public class ArgumentDecimalBetweenGuardTest + { + [Theory] + [InlineData(4, 3, 8)] + [InlineData(5, 3, 8)] + [InlineData(7, 3, 8)] + public void + Decimal_ThrowIfIsBetween_Should_Throw_Exception_When_Argument_Is_Between_Start_And_End_Value(decimal argument, decimal compareValueStart, decimal compareValueEnd) + { + var exception = Assert.Throws(() => + { + argument.ThrowIfIsBetween(compareValueStart, compareValueEnd, nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is between {compareValueStart} and {compareValueEnd}.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be($"Argument is between {compareValueStart} and {compareValueEnd}. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Theory] + [InlineData(2, 3, 8)] + [InlineData(1, 3, 8)] + [InlineData(9, 3, 8)] + [InlineData(10, 3, 8)] + public void + Decimal_ThrowIfIsBetween_Should_Not_Throw_Exception_When_Argument_Is_Between_Start_And_End_Value(decimal argument, decimal compareValueStart, decimal compareValueEnd) + { + var exception = Record.Exception(() => + { + argument.ThrowIfIsBetween(compareValueStart, compareValueEnd, nameof(argument)); + }); + Assert.Null(exception); + } + } } \ No newline at end of file diff --git a/src/oehen.arguard.Tests/Between/ArgumentIntBetweenGuardTest.cs b/src/oehen.arguard.Tests/Between/ArgumentIntBetweenGuardTest.cs index 30e18f55..52d06850 100644 --- a/src/oehen.arguard.Tests/Between/ArgumentIntBetweenGuardTest.cs +++ b/src/oehen.arguard.Tests/Between/ArgumentIntBetweenGuardTest.cs @@ -1,40 +1,46 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace oehen.arguard.Between -{ - [UseCulture("en-US")] - public class ArgumentIntBetweenGuardTest - { - [Theory] - [InlineData(4, 3, 8)] - [InlineData(5, 3, 8)] - [InlineData(7, 3, 8)] - public void - Int_ThrowIfIsBetween_Should_Throw_Exception_When_Argument_Is_Between_Start_And_End_Value( - int argument, int compareValueStart, int compareValueEnd) - { - var exception = Assert.Throws(() => - { - argument.ThrowIfIsBetween(compareValueStart, compareValueEnd, nameof(argument)); - }); - exception.Message.Should().Be($"Argument is between {compareValueStart} and {compareValueEnd}. (Parameter 'argument')" + - Environment.NewLine + $"Actual value was {argument}."); - } - [Theory] - [InlineData(2, 3, 8)] - [InlineData(1, 3, 8)] - [InlineData(9, 3, 8)] - [InlineData(10, 3, 8)] - public void - Int_ThrowIfIsBetween_Should_Not_Throw_Exception_When_Argument_Is_Between_Start_And_End_Value(int argument, int compareValueStart, int compareValueEnd) - { - var exception = Record.Exception(() => - { - argument.ThrowIfIsBetween(compareValueStart, compareValueEnd, nameof(argument)); - }); - Assert.Null(exception); - } - } +using System; +using FluentAssertions; +using Xunit; + +namespace oehen.arguard.Between +{ + [UseCulture("en-US")] + public class ArgumentIntBetweenGuardTest + { + [Theory] + [InlineData(4, 3, 8)] + [InlineData(5, 3, 8)] + [InlineData(7, 3, 8)] + public void + Int_ThrowIfIsBetween_Should_Throw_Exception_When_Argument_Is_Between_Start_And_End_Value( + int argument, int compareValueStart, int compareValueEnd) + { + var exception = Assert.Throws(() => + { + argument.ThrowIfIsBetween(compareValueStart, compareValueEnd, nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is between {compareValueStart} and {compareValueEnd}.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be($"Argument is between {compareValueStart} and {compareValueEnd}. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Theory] + [InlineData(2, 3, 8)] + [InlineData(1, 3, 8)] + [InlineData(9, 3, 8)] + [InlineData(10, 3, 8)] + public void + Int_ThrowIfIsBetween_Should_Not_Throw_Exception_When_Argument_Is_Between_Start_And_End_Value(int argument, int compareValueStart, int compareValueEnd) + { + var exception = Record.Exception(() => + { + argument.ThrowIfIsBetween(compareValueStart, compareValueEnd, nameof(argument)); + }); + Assert.Null(exception); + } + } } \ No newline at end of file diff --git a/src/oehen.arguard.Tests/Between/ArgumentLongBetweenGuardTest.cs b/src/oehen.arguard.Tests/Between/ArgumentLongBetweenGuardTest.cs index 7cce2a98..21f3cfa4 100644 --- a/src/oehen.arguard.Tests/Between/ArgumentLongBetweenGuardTest.cs +++ b/src/oehen.arguard.Tests/Between/ArgumentLongBetweenGuardTest.cs @@ -1,40 +1,45 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace oehen.arguard.Between -{ - [UseCulture("en-US")] - public class ArgumentLongBetweenGuardTest - { - [Theory] - [InlineData(4, 3, 8)] - [InlineData(5, 3, 8)] - [InlineData(7, 3, 8)] - public void - Long_ThrowIfIsBetween_Should_Throw_Exception_When_Argument_Is_Between_Start_And_End_Value(long argument, long compareValueStart, long compareValueEnd) - { - var exception = Assert.Throws(() => - { - argument.ThrowIfIsBetween(compareValueStart, compareValueEnd, nameof(argument)); - }); - exception.Message.Should().Be($"Argument is between {compareValueStart} and {compareValueEnd}. (Parameter 'argument')" + - Environment.NewLine + $"Actual value was {argument}."); - } - - [Theory] - [InlineData(2, 3, 8)] - [InlineData(1, 3, 8)] - [InlineData(9, 3, 8)] - [InlineData(10, 3, 8)] - public void - Long_ThrowIfIsBetween_Should_Not_Throw_Exception_When_Argument_Is_Between_Start_And_End_Value(long argument, long compareValueStart, long compareValueEnd) - { - var exception = Record.Exception(() => - { - argument.ThrowIfIsBetween(compareValueStart, compareValueEnd, nameof(argument)); - }); - Assert.Null(exception); - } - } +using System; +using FluentAssertions; +using Xunit; + +namespace oehen.arguard.Between +{ + [UseCulture("en-US")] + public class ArgumentLongBetweenGuardTest + { + [Theory] + [InlineData(4, 3, 8)] + [InlineData(5, 3, 8)] + [InlineData(7, 3, 8)] + public void + Long_ThrowIfIsBetween_Should_Throw_Exception_When_Argument_Is_Between_Start_And_End_Value(long argument, long compareValueStart, long compareValueEnd) + { + var exception = Assert.Throws(() => + { + argument.ThrowIfIsBetween(compareValueStart, compareValueEnd, nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is between {compareValueStart} and {compareValueEnd}.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be($"Argument is between {compareValueStart} and {compareValueEnd}. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Theory] + [InlineData(2, 3, 8)] + [InlineData(1, 3, 8)] + [InlineData(9, 3, 8)] + [InlineData(10, 3, 8)] + public void + Long_ThrowIfIsBetween_Should_Not_Throw_Exception_When_Argument_Is_Between_Start_And_End_Value(long argument, long compareValueStart, long compareValueEnd) + { + var exception = Record.Exception(() => + { + argument.ThrowIfIsBetween(compareValueStart, compareValueEnd, nameof(argument)); + }); + Assert.Null(exception); + } + } } \ No newline at end of file diff --git a/src/oehen.arguard.Tests/LessThan/ArgumentDecimalLessOrEqualThanZeroGuardTest.cs b/src/oehen.arguard.Tests/LessThan/ArgumentDecimalLessOrEqualThanZeroGuardTest.cs index 8dfbefcc..330a5de5 100644 --- a/src/oehen.arguard.Tests/LessThan/ArgumentDecimalLessOrEqualThanZeroGuardTest.cs +++ b/src/oehen.arguard.Tests/LessThan/ArgumentDecimalLessOrEqualThanZeroGuardTest.cs @@ -1,51 +1,62 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace oehen.arguard.LessThan -{ - [UseCulture("en-US")] - public class ArgumentDecimalLessOrEqualThanZeroGuardTest - { - [Theory] - [InlineData(-1.33)] - [InlineData(-2.55)] - [InlineData(-3.5889)] - [InlineData(-123456.789)] - public void Decimal_ThrowIfIsLessOrEqualThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsNegative( - decimal argument) - { - var exception = Assert.Throws(() => - { - argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); - }); - exception.Message.Should().Be("Argument is less or equal than 0. (Parameter 'argument')" + - Environment.NewLine + $"Actual value was {argument}."); - } - - [Fact] - public void Decimal_ThrowIfIsLessOrEqualThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentIsZero() - { - const decimal argument = 0; - var exception = Assert.Throws(() => - { - argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); - }); - exception.Message.Should().Be("Argument is less or equal than 0. (Parameter 'argument')" + - Environment.NewLine + "Actual value was 0."); - } - - [Theory] - [InlineData(1.23)] - [InlineData(2.23)] - [InlineData(3.23)] - [InlineData(123456.23)] - [InlineData(int.MaxValue)] - public void Decimal_ThrowIfIsLessOrEqualThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsMoreThanZero( - decimal argument) - { - var exception = Record.Exception(() => { argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); }); - Assert.Null(exception); - } - } +using System; +using FluentAssertions; +using Xunit; + +namespace oehen.arguard.LessThan +{ + [UseCulture("en-US")] + public class ArgumentDecimalLessOrEqualThanZeroGuardTest + { + [Theory] + [InlineData(-1.33)] + [InlineData(-2.55)] + [InlineData(-3.5889)] + [InlineData(-123456.789)] + public void Decimal_ThrowIfIsLessOrEqualThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsNegative( + decimal argument) + { + var exception = Assert.Throws(() => + { + argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is less or equal than 0.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be("Argument is less or equal than 0. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Fact] + public void Decimal_ThrowIfIsLessOrEqualThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentIsZero() + { + const decimal argument = 0; + var exception = Assert.Throws(() => + { + argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); + }); + +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is less or equal than 0.\r\nParameter name: argument\r\nActual value was 0."); +#else + exception.Message.Should().Be("Argument is less or equal than 0. (Parameter 'argument')" + + Environment.NewLine + "Actual value was 0."); +#endif + } + + [Theory] + [InlineData(1.23)] + [InlineData(2.23)] + [InlineData(3.23)] + [InlineData(123456.23)] + [InlineData(int.MaxValue)] + public void Decimal_ThrowIfIsLessOrEqualThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsMoreThanZero( + decimal argument) + { + var exception = Record.Exception(() => { argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); }); + Assert.Null(exception); + } + } } \ No newline at end of file diff --git a/src/oehen.arguard.Tests/LessThan/ArgumentDecimalLessThanGuardTest.cs b/src/oehen.arguard.Tests/LessThan/ArgumentDecimalLessThanGuardTest.cs index 1c831ea0..83869231 100644 --- a/src/oehen.arguard.Tests/LessThan/ArgumentDecimalLessThanGuardTest.cs +++ b/src/oehen.arguard.Tests/LessThan/ArgumentDecimalLessThanGuardTest.cs @@ -1,71 +1,81 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace oehen.arguard.LessThan -{ - [UseCulture("en-US")] - public class ArgumentDecimalLessThanGuardTest - { - [Theory] - [InlineData(-1.23, 0.23)] - [InlineData(2.23, 3.23)] - [InlineData(-3.23, 5.23)] - [InlineData(5.23, 5.23)] - public void - Decimal_ThrowIfIsLessOrEqualThanCompareValue_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsLessOrEqualThanTheCompareValue( - decimal argument, decimal compareValue) - { - var exception = Assert.Throws(() => - { - argument.ThrowIfIsLessOrEqualThan(compareValue, nameof(argument)); - }); - exception.Message.Should().Be($"Argument is less or equal than {compareValue}. (Parameter 'argument')" + - Environment.NewLine + $"Actual value was {argument}."); - } - - [Theory] - [InlineData(-1.23, 0.23)] - [InlineData(2.23, 3.23)] - [InlineData(-3.23, 5.23)] - public void - Decimal_ThrowIfIsLessThanCompareValue_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsLessThanTheCompareValue( - decimal argument, decimal compareValue) - { - var exception = Assert.Throws(() => - { - argument.ThrowIfIsLessThan(compareValue, nameof(argument)); - }); - exception.Message.Should().Be($"Argument is less than {compareValue}. (Parameter 'argument')" + - Environment.NewLine + $"Actual value was {argument}."); - } - - [Theory] - [InlineData(11.23, 2.23)] - [InlineData(3.23, 2.23)] - [InlineData(5.23, 3.23)] - [InlineData(3.23, 3.23)] - public void - Decimal_ThrowIfIsLessThanCompareValue_ShouldNotThrowArgumentOutOfRangeException_IfArgumentValueIsGreaterThanTheCompareValue( - decimal argument, decimal compareValue) - { - var exception = Record.Exception(() => { argument.ThrowIfIsLessThan(compareValue, nameof(argument)); }); - Assert.Null(exception); - } - - [Theory] - [InlineData(11.23, 2.23)] - [InlineData(3.23, 2.23)] - [InlineData(5.23, 3.23)] - public void - Decimal_ThrowIfIsLessOrEqualThanCompareValue_ShouldNotThrowArgumentOutOfRangeException_IfArgumentValueIsGreaterOrEqualThanTheCompareValue( - decimal argument, decimal compareValue) - { - var exception = Record.Exception(() => - { - argument.ThrowIfIsLessOrEqualThan(compareValue, nameof(argument)); - }); - Assert.Null(exception); - } - } +using System; +using FluentAssertions; +using Xunit; + +namespace oehen.arguard.LessThan +{ + [UseCulture("en-US")] + public class ArgumentDecimalLessThanGuardTest + { + [Theory] + [InlineData(-1.23, 0.23)] + [InlineData(2.23, 3.23)] + [InlineData(-3.23, 5.23)] + [InlineData(5.23, 5.23)] + public void + Decimal_ThrowIfIsLessOrEqualThanCompareValue_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsLessOrEqualThanTheCompareValue( + decimal argument, decimal compareValue) + { + var exception = Assert.Throws(() => + { + argument.ThrowIfIsLessOrEqualThan(compareValue, nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is less or equal than {compareValue}.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be($"Argument is less or equal than {compareValue}. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Theory] + [InlineData(-1.23, 0.23)] + [InlineData(2.23, 3.23)] + [InlineData(-3.23, 5.23)] + public void + Decimal_ThrowIfIsLessThanCompareValue_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsLessThanTheCompareValue( + decimal argument, decimal compareValue) + { + var exception = Assert.Throws(() => + { + argument.ThrowIfIsLessThan(compareValue, nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is less than {compareValue}.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be($"Argument is less than {compareValue}. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Theory] + [InlineData(11.23, 2.23)] + [InlineData(3.23, 2.23)] + [InlineData(5.23, 3.23)] + [InlineData(3.23, 3.23)] + public void + Decimal_ThrowIfIsLessThanCompareValue_ShouldNotThrowArgumentOutOfRangeException_IfArgumentValueIsGreaterThanTheCompareValue( + decimal argument, decimal compareValue) + { + var exception = Record.Exception(() => { argument.ThrowIfIsLessThan(compareValue, nameof(argument)); }); + Assert.Null(exception); + } + + [Theory] + [InlineData(11.23, 2.23)] + [InlineData(3.23, 2.23)] + [InlineData(5.23, 3.23)] + public void + Decimal_ThrowIfIsLessOrEqualThanCompareValue_ShouldNotThrowArgumentOutOfRangeException_IfArgumentValueIsGreaterOrEqualThanTheCompareValue( + decimal argument, decimal compareValue) + { + var exception = Record.Exception(() => + { + argument.ThrowIfIsLessOrEqualThan(compareValue, nameof(argument)); + }); + Assert.Null(exception); + } + } } \ No newline at end of file diff --git a/src/oehen.arguard.Tests/LessThan/ArgumentDecimalLessThanZeroGuardTest.cs b/src/oehen.arguard.Tests/LessThan/ArgumentDecimalLessThanZeroGuardTest.cs index d45fb63c..f3740341 100644 --- a/src/oehen.arguard.Tests/LessThan/ArgumentDecimalLessThanZeroGuardTest.cs +++ b/src/oehen.arguard.Tests/LessThan/ArgumentDecimalLessThanZeroGuardTest.cs @@ -1,45 +1,50 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace oehen.arguard.LessThan -{ - [UseCulture("en-US")] - public class ArgumentDecimalLessThanZeroGuardTest - { - [Theory] - [InlineData(-1.33)] - [InlineData(-2.55)] - [InlineData(-3.5889)] - [InlineData(-123456.789)] - public void Decimal_ThrowIfIsLessThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsNegative(decimal argument) - { - var exception = Assert.Throws(() => - { - argument.ThrowIfIsLessThanZero(nameof(argument)); - }); - exception.Message.Should().Be("Argument is less than 0. (Parameter 'argument')" + - Environment.NewLine + $"Actual value was {argument}."); - } - - [Theory] - [InlineData(1.33)] - [InlineData(2.55)] - [InlineData(3.5889)] - [InlineData(123456)] - public void Decimal_ThrowIfIsLessThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsMoreThanZero( - decimal argument) - { - var exception = Record.Exception(() => { argument.ThrowIfIsLessThanZero(nameof(argument)); }); - Assert.Null(exception); - } - - [Fact] - public void Decimal_ThrowIfIsLessThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsZero() - { - const decimal argument = 0; - var exception = Record.Exception(() => { argument.ThrowIfIsLessThanZero(nameof(argument)); }); - Assert.Null(exception); - } - } +using System; +using FluentAssertions; +using Xunit; + +namespace oehen.arguard.LessThan +{ + [UseCulture("en-US")] + public class ArgumentDecimalLessThanZeroGuardTest + { + [Theory] + [InlineData(-1.33)] + [InlineData(-2.55)] + [InlineData(-3.5889)] + [InlineData(-123456.789)] + public void Decimal_ThrowIfIsLessThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsNegative(decimal argument) + { + var exception = Assert.Throws(() => + { + argument.ThrowIfIsLessThanZero(nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is less than 0.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be("Argument is less than 0. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Theory] + [InlineData(1.33)] + [InlineData(2.55)] + [InlineData(3.5889)] + [InlineData(123456)] + public void Decimal_ThrowIfIsLessThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsMoreThanZero( + decimal argument) + { + var exception = Record.Exception(() => { argument.ThrowIfIsLessThanZero(nameof(argument)); }); + Assert.Null(exception); + } + + [Fact] + public void Decimal_ThrowIfIsLessThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsZero() + { + const decimal argument = 0; + var exception = Record.Exception(() => { argument.ThrowIfIsLessThanZero(nameof(argument)); }); + Assert.Null(exception); + } + } } \ No newline at end of file diff --git a/src/oehen.arguard.Tests/LessThan/ArgumentIntLessOrEqualThanZeroGuardTest.cs b/src/oehen.arguard.Tests/LessThan/ArgumentIntLessOrEqualThanZeroGuardTest.cs index 17a77af3..c9479ba4 100644 --- a/src/oehen.arguard.Tests/LessThan/ArgumentIntLessOrEqualThanZeroGuardTest.cs +++ b/src/oehen.arguard.Tests/LessThan/ArgumentIntLessOrEqualThanZeroGuardTest.cs @@ -1,51 +1,61 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace oehen.arguard.LessThan -{ - [UseCulture("en-US")] - public class ArgumentIntLessOrEqualThanZeroGuardTest - { - [Theory] - [InlineData(-1)] - [InlineData(-2)] - [InlineData(-3)] - [InlineData(-123456)] - public void Int_ThrowIfIsLessOrEqualThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsNegative( - int argument) - { - var exception = Assert.Throws(() => - { - argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); - }); - exception.Message.Should().Be("Argument is less or equal than 0. (Parameter 'argument')" + - Environment.NewLine + $"Actual value was {argument}."); - } - - [Fact] - public void Int_ThrowIfIsLessOrEqualThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentIsZero() - { - const int argument = 0; - var exception = Assert.Throws(() => - { - argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); - }); - exception.Message.Should().Be("Argument is less or equal than 0. (Parameter 'argument')" + - Environment.NewLine + "Actual value was 0."); - } - - [Theory] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(123456)] - [InlineData(int.MaxValue)] - public void Int_ThrowIfIsLessOrEqualThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsMoreThanZero( - int argument) - { - var exception = Record.Exception(() => { argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); }); - Assert.Null(exception); - } - } +using System; +using FluentAssertions; +using Xunit; + +namespace oehen.arguard.LessThan +{ + [UseCulture("en-US")] + public class ArgumentIntLessOrEqualThanZeroGuardTest + { + [Theory] + [InlineData(-1)] + [InlineData(-2)] + [InlineData(-3)] + [InlineData(-123456)] + public void Int_ThrowIfIsLessOrEqualThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsNegative( + int argument) + { + var exception = Assert.Throws(() => + { + argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is less or equal than 0.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be("Argument is less or equal than 0. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Fact] + public void Int_ThrowIfIsLessOrEqualThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentIsZero() + { + const int argument = 0; + var exception = Assert.Throws(() => + { + argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is less or equal than 0.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be("Argument is less or equal than 0. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Theory] + [InlineData(1)] + [InlineData(2)] + [InlineData(3)] + [InlineData(123456)] + [InlineData(int.MaxValue)] + public void Int_ThrowIfIsLessOrEqualThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsMoreThanZero( + int argument) + { + var exception = Record.Exception(() => { argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); }); + Assert.Null(exception); + } + } } \ No newline at end of file diff --git a/src/oehen.arguard.Tests/LessThan/ArgumentIntLessThanGuardTest.cs b/src/oehen.arguard.Tests/LessThan/ArgumentIntLessThanGuardTest.cs index 193ae548..0f67c756 100644 --- a/src/oehen.arguard.Tests/LessThan/ArgumentIntLessThanGuardTest.cs +++ b/src/oehen.arguard.Tests/LessThan/ArgumentIntLessThanGuardTest.cs @@ -1,71 +1,81 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace oehen.arguard.LessThan -{ - [UseCulture("en-US")] - public class ArgumentIntLessThanGuardTest - { - [Theory] - [InlineData(-1, 0)] - [InlineData(2, 3)] - [InlineData(-3, 5)] - [InlineData(5, 5)] - public void - Int_ThrowIfIsLessOrEqualThanCompareValue_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsLessOrEqualThanTheCompareValue( - int argument, int compareValue) - { - var exception = Assert.Throws(() => - { - argument.ThrowIfIsLessOrEqualThan(compareValue, nameof(argument)); - }); - exception.Message.Should().Be($"Argument is less or equal than {compareValue}. (Parameter 'argument')" + - Environment.NewLine + $"Actual value was {argument}."); - } - - [Theory] - [InlineData(-1, 0)] - [InlineData(2, 3)] - [InlineData(-3, 5)] - public void - Int_ThrowIfIsLessThanCompareValue_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsLessThanTheCompareValue( - int argument, int compareValue) - { - var exception = Assert.Throws(() => - { - argument.ThrowIfIsLessThan(compareValue, nameof(argument)); - }); - exception.Message.Should().Be($"Argument is less than {compareValue}. (Parameter 'argument')" + - Environment.NewLine + $"Actual value was {argument}."); - } - - [Theory] - [InlineData(11, 2)] - [InlineData(3, 2)] - [InlineData(5, 3)] - [InlineData(3, 3)] - public void - Int_ThrowIfIsLessThanCompareValue_ShouldNotThrowArgumentOutOfRangeException_IfArgumentValueIsGreaterThanTheCompareValue( - int argument, int compareValue) - { - var exception = Record.Exception(() => { argument.ThrowIfIsLessThan(compareValue, nameof(argument)); }); - Assert.Null(exception); - } - - [Theory] - [InlineData(11, 2)] - [InlineData(3, 2)] - [InlineData(5, 3)] - public void - Int_ThrowIfIsLessOrEqualThanCompareValue_ShouldNotThrowArgumentOutOfRangeException_IfArgumentValueIsGreaterOrEqualThanTheCompareValue( - int argument, int compareValue) - { - var exception = Record.Exception(() => - { - argument.ThrowIfIsLessOrEqualThan(compareValue, nameof(argument)); - }); - Assert.Null(exception); - } - } +using System; +using FluentAssertions; +using Xunit; + +namespace oehen.arguard.LessThan +{ + [UseCulture("en-US")] + public class ArgumentIntLessThanGuardTest + { + [Theory] + [InlineData(-1, 0)] + [InlineData(2, 3)] + [InlineData(-3, 5)] + [InlineData(5, 5)] + public void + Int_ThrowIfIsLessOrEqualThanCompareValue_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsLessOrEqualThanTheCompareValue( + int argument, int compareValue) + { + var exception = Assert.Throws(() => + { + argument.ThrowIfIsLessOrEqualThan(compareValue, nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is less or equal than {compareValue}.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be($"Argument is less or equal than {compareValue}. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Theory] + [InlineData(-1, 0)] + [InlineData(2, 3)] + [InlineData(-3, 5)] + public void + Int_ThrowIfIsLessThanCompareValue_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsLessThanTheCompareValue( + int argument, int compareValue) + { + var exception = Assert.Throws(() => + { + argument.ThrowIfIsLessThan(compareValue, nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is less than {compareValue}.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be($"Argument is less than {compareValue}. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Theory] + [InlineData(11, 2)] + [InlineData(3, 2)] + [InlineData(5, 3)] + [InlineData(3, 3)] + public void + Int_ThrowIfIsLessThanCompareValue_ShouldNotThrowArgumentOutOfRangeException_IfArgumentValueIsGreaterThanTheCompareValue( + int argument, int compareValue) + { + var exception = Record.Exception(() => { argument.ThrowIfIsLessThan(compareValue, nameof(argument)); }); + Assert.Null(exception); + } + + [Theory] + [InlineData(11, 2)] + [InlineData(3, 2)] + [InlineData(5, 3)] + public void + Int_ThrowIfIsLessOrEqualThanCompareValue_ShouldNotThrowArgumentOutOfRangeException_IfArgumentValueIsGreaterOrEqualThanTheCompareValue( + int argument, int compareValue) + { + var exception = Record.Exception(() => + { + argument.ThrowIfIsLessOrEqualThan(compareValue, nameof(argument)); + }); + Assert.Null(exception); + } + } } \ No newline at end of file diff --git a/src/oehen.arguard.Tests/LessThan/ArgumentIntLessThanZeroGuardTest.cs b/src/oehen.arguard.Tests/LessThan/ArgumentIntLessThanZeroGuardTest.cs index 64dd1eb3..c5735daa 100644 --- a/src/oehen.arguard.Tests/LessThan/ArgumentIntLessThanZeroGuardTest.cs +++ b/src/oehen.arguard.Tests/LessThan/ArgumentIntLessThanZeroGuardTest.cs @@ -1,46 +1,51 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace oehen.arguard.LessThan -{ - [UseCulture("en-US")] - public class ArgumentIntLessThanZeroGuardTest - { - [Theory] - [InlineData(-1)] - [InlineData(-2)] - [InlineData(-3)] - [InlineData(-123456)] - public void Int_ThrowIfIsLessThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsNegative(int argument) - { - var exception = Assert.Throws(() => - { - argument.ThrowIfIsLessThanZero(nameof(argument)); - }); - exception.Message.Should().Be("Argument is less than 0. (Parameter 'argument')" + - Environment.NewLine + $"Actual value was {argument}."); - } - - [Theory] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(123456)] - [InlineData(int.MaxValue)] - public void Int_ThrowIfIsLessThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsMoreThanZero( - int argument) - { - var exception = Record.Exception(() => { argument.ThrowIfIsLessThanZero(nameof(argument)); }); - Assert.Null(exception); - } - - [Fact] - public void Int_ThrowIfIsLessThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsZero() - { - const int argument = 0; - var exception = Record.Exception(() => { argument.ThrowIfIsLessThanZero(nameof(argument)); }); - Assert.Null(exception); - } - } +using System; +using FluentAssertions; +using Xunit; + +namespace oehen.arguard.LessThan +{ + [UseCulture("en-US")] + public class ArgumentIntLessThanZeroGuardTest + { + [Theory] + [InlineData(-1)] + [InlineData(-2)] + [InlineData(-3)] + [InlineData(-123456)] + public void Int_ThrowIfIsLessThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsNegative(int argument) + { + var exception = Assert.Throws(() => + { + argument.ThrowIfIsLessThanZero(nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is less than 0.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be("Argument is less than 0. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Theory] + [InlineData(1)] + [InlineData(2)] + [InlineData(3)] + [InlineData(123456)] + [InlineData(int.MaxValue)] + public void Int_ThrowIfIsLessThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsMoreThanZero( + int argument) + { + var exception = Record.Exception(() => { argument.ThrowIfIsLessThanZero(nameof(argument)); }); + Assert.Null(exception); + } + + [Fact] + public void Int_ThrowIfIsLessThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsZero() + { + const int argument = 0; + var exception = Record.Exception(() => { argument.ThrowIfIsLessThanZero(nameof(argument)); }); + Assert.Null(exception); + } + } } \ No newline at end of file diff --git a/src/oehen.arguard.Tests/LessThan/ArgumentLongLessOrEqualThanZeroGuardTest.cs b/src/oehen.arguard.Tests/LessThan/ArgumentLongLessOrEqualThanZeroGuardTest.cs index bca99836..8ea1efdc 100644 --- a/src/oehen.arguard.Tests/LessThan/ArgumentLongLessOrEqualThanZeroGuardTest.cs +++ b/src/oehen.arguard.Tests/LessThan/ArgumentLongLessOrEqualThanZeroGuardTest.cs @@ -1,51 +1,61 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace oehen.arguard.LessThan -{ - [UseCulture("en-US")] - public class ArgumentLongLessOrEqualThanZeroGuardTest - { - [Theory] - [InlineData(-1)] - [InlineData(-2)] - [InlineData(-3)] - [InlineData(-123456)] - public void Long_ThrowIfIsLessOrEqualThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsNegative( - long argument) - { - var exception = Assert.Throws(() => - { - argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); - }); - exception.Message.Should().Be("Argument is less or equal than 0. (Parameter 'argument')" + - Environment.NewLine + $"Actual value was {argument}."); - } - - [Fact] - public void Long_ThrowIfIsLessOrEqualThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentIsZero() - { - const long argument = 0; - var exception = Assert.Throws(() => - { - argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); - }); - exception.Message.Should().Be("Argument is less or equal than 0. (Parameter 'argument')" + - Environment.NewLine + "Actual value was 0."); - } - - [Theory] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(123456)] - [InlineData(int.MaxValue)] - public void Long_ThrowIfIsLessOrEqualThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsMoreThanZero( - long argument) - { - var exception = Record.Exception(() => { argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); }); - Assert.Null(exception); - } - } +using System; +using FluentAssertions; +using Xunit; + +namespace oehen.arguard.LessThan +{ + [UseCulture("en-US")] + public class ArgumentLongLessOrEqualThanZeroGuardTest + { + [Theory] + [InlineData(-1)] + [InlineData(-2)] + [InlineData(-3)] + [InlineData(-123456)] + public void Long_ThrowIfIsLessOrEqualThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsNegative( + long argument) + { + var exception = Assert.Throws(() => + { + argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is less or equal than 0.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be("Argument is less or equal than 0. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Fact] + public void Long_ThrowIfIsLessOrEqualThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentIsZero() + { + const long argument = 0; + var exception = Assert.Throws(() => + { + argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is less or equal than 0.\r\nParameter name: argument\r\nActual value was 0."); +#else + exception.Message.Should().Be("Argument is less or equal than 0. (Parameter 'argument')" + + Environment.NewLine + "Actual value was 0."); +#endif + } + + [Theory] + [InlineData(1)] + [InlineData(2)] + [InlineData(3)] + [InlineData(123456)] + [InlineData(int.MaxValue)] + public void Long_ThrowIfIsLessOrEqualThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsMoreThanZero( + long argument) + { + var exception = Record.Exception(() => { argument.ThrowIfIsLessOrEqualThanZero(nameof(argument)); }); + Assert.Null(exception); + } + } } \ No newline at end of file diff --git a/src/oehen.arguard.Tests/LessThan/ArgumentLongLessThanGuardTest.cs b/src/oehen.arguard.Tests/LessThan/ArgumentLongLessThanGuardTest.cs index 3605bad7..8f220774 100644 --- a/src/oehen.arguard.Tests/LessThan/ArgumentLongLessThanGuardTest.cs +++ b/src/oehen.arguard.Tests/LessThan/ArgumentLongLessThanGuardTest.cs @@ -1,71 +1,81 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace oehen.arguard.LessThan -{ - [UseCulture("en-US")] - public class ArgumentLongLessThanGuardTest - { - [Theory] - [InlineData(-1, 0)] - [InlineData(2, 3)] - [InlineData(-3, 5)] - [InlineData(5, 5)] - public void - Long_ThrowIfIsLessOrEqualThanCompareValue_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsLessOrEqualThanTheCompareValue( - long argument, long compareValue) - { - var exception = Assert.Throws(() => - { - argument.ThrowIfIsLessOrEqualThan(compareValue, nameof(argument)); - }); - exception.Message.Should().Be($"Argument is less or equal than {compareValue}. (Parameter 'argument')" + - Environment.NewLine + $"Actual value was {argument}."); - } - - [Theory] - [InlineData(-1, 0)] - [InlineData(2, 3)] - [InlineData(-3, 5)] - public void - Long_ThrowIfIsLessThanCompareValue_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsLessThanTheCompareValue( - long argument, long compareValue) - { - var exception = Assert.Throws(() => - { - argument.ThrowIfIsLessThan(compareValue, nameof(argument)); - }); - exception.Message.Should().Be($"Argument is less than {compareValue}. (Parameter 'argument')" + - Environment.NewLine + $"Actual value was {argument}."); - } - - [Theory] - [InlineData(11, 2)] - [InlineData(3, 2)] - [InlineData(5, 3)] - [InlineData(3, 3)] - public void - Long_ThrowIfIsLessThanCompareValue_ShouldNotThrowArgumentOutOfRangeException_IfArgumentValueIsGreaterThanTheCompareValue( - long argument, long compareValue) - { - var exception = Record.Exception(() => { argument.ThrowIfIsLessThan(compareValue, nameof(argument)); }); - Assert.Null(exception); - } - - [Theory] - [InlineData(11, 2)] - [InlineData(3, 2)] - [InlineData(5, 3)] - public void - Long_ThrowIfIsLessOrEqualThanCompareValue_ShouldNotThrowArgumentOutOfRangeException_IfArgumentValueIsGreaterOrEqualThanTheCompareValue( - long argument, long compareValue) - { - var exception = Record.Exception(() => - { - argument.ThrowIfIsLessOrEqualThan(compareValue, nameof(argument)); - }); - Assert.Null(exception); - } - } +using System; +using FluentAssertions; +using Xunit; + +namespace oehen.arguard.LessThan +{ + [UseCulture("en-US")] + public class ArgumentLongLessThanGuardTest + { + [Theory] + [InlineData(-1, 0)] + [InlineData(2, 3)] + [InlineData(-3, 5)] + [InlineData(5, 5)] + public void + Long_ThrowIfIsLessOrEqualThanCompareValue_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsLessOrEqualThanTheCompareValue( + long argument, long compareValue) + { + var exception = Assert.Throws(() => + { + argument.ThrowIfIsLessOrEqualThan(compareValue, nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is less or equal than {compareValue}.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be($"Argument is less or equal than {compareValue}. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Theory] + [InlineData(-1, 0)] + [InlineData(2, 3)] + [InlineData(-3, 5)] + public void + Long_ThrowIfIsLessThanCompareValue_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsLessThanTheCompareValue( + long argument, long compareValue) + { + var exception = Assert.Throws(() => + { + argument.ThrowIfIsLessThan(compareValue, nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is less than {compareValue}.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be($"Argument is less than {compareValue}. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Theory] + [InlineData(11, 2)] + [InlineData(3, 2)] + [InlineData(5, 3)] + [InlineData(3, 3)] + public void + Long_ThrowIfIsLessThanCompareValue_ShouldNotThrowArgumentOutOfRangeException_IfArgumentValueIsGreaterThanTheCompareValue( + long argument, long compareValue) + { + var exception = Record.Exception(() => { argument.ThrowIfIsLessThan(compareValue, nameof(argument)); }); + Assert.Null(exception); + } + + [Theory] + [InlineData(11, 2)] + [InlineData(3, 2)] + [InlineData(5, 3)] + public void + Long_ThrowIfIsLessOrEqualThanCompareValue_ShouldNotThrowArgumentOutOfRangeException_IfArgumentValueIsGreaterOrEqualThanTheCompareValue( + long argument, long compareValue) + { + var exception = Record.Exception(() => + { + argument.ThrowIfIsLessOrEqualThan(compareValue, nameof(argument)); + }); + Assert.Null(exception); + } + } } \ No newline at end of file diff --git a/src/oehen.arguard.Tests/LessThan/ArgumentLongLessThanZeroGuardTest.cs b/src/oehen.arguard.Tests/LessThan/ArgumentLongLessThanZeroGuardTest.cs index 74ad6abe..cfd0ee12 100644 --- a/src/oehen.arguard.Tests/LessThan/ArgumentLongLessThanZeroGuardTest.cs +++ b/src/oehen.arguard.Tests/LessThan/ArgumentLongLessThanZeroGuardTest.cs @@ -1,46 +1,51 @@ -using System; -using FluentAssertions; -using Xunit; - -namespace oehen.arguard.LessThan -{ - [UseCulture("en-US")] - public class ArgumentLongLessThanZeroGuardTest - { - [Theory] - [InlineData(-1)] - [InlineData(-2)] - [InlineData(-3)] - [InlineData(-123456)] - public void Long_ThrowIfIsLessThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsNegative(long argument) - { - var exception = Assert.Throws(() => - { - argument.ThrowIfIsLessThanZero(nameof(argument)); - }); - exception.Message.Should().Be("Argument is less than 0. (Parameter 'argument')" + - Environment.NewLine + $"Actual value was {argument}."); - } - - [Theory] - [InlineData(1)] - [InlineData(2)] - [InlineData(3)] - [InlineData(123456)] - [InlineData(int.MaxValue)] - public void Long_ThrowIfIsLessThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsMoreThanZero( - long argument) - { - var exception = Record.Exception(() => { argument.ThrowIfIsLessThanZero(nameof(argument)); }); - Assert.Null(exception); - } - - [Fact] - public void Long_ThrowIfIsLessThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsZero() - { - const int argument = 0; - var exception = Record.Exception(() => { argument.ThrowIfIsLessThanZero(nameof(argument)); }); - Assert.Null(exception); - } - } +using System; +using FluentAssertions; +using Xunit; + +namespace oehen.arguard.LessThan +{ + [UseCulture("en-US")] + public class ArgumentLongLessThanZeroGuardTest + { + [Theory] + [InlineData(-1)] + [InlineData(-2)] + [InlineData(-3)] + [InlineData(-123456)] + public void Long_ThrowIfIsLessThanZero_ShouldThrowArgumentOutOfRangeException_IfArgumentValueIsNegative(long argument) + { + var exception = Assert.Throws(() => + { + argument.ThrowIfIsLessThanZero(nameof(argument)); + }); +#if NET472 +#elif NET48 + exception.Message.Should().Be($"Argument is less than 0.\r\nParameter name: argument\r\nActual value was {argument}."); +#else + exception.Message.Should().Be("Argument is less than 0. (Parameter 'argument')" + + Environment.NewLine + $"Actual value was {argument}."); +#endif + } + + [Theory] + [InlineData(1)] + [InlineData(2)] + [InlineData(3)] + [InlineData(123456)] + [InlineData(int.MaxValue)] + public void Long_ThrowIfIsLessThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsMoreThanZero( + long argument) + { + var exception = Record.Exception(() => { argument.ThrowIfIsLessThanZero(nameof(argument)); }); + Assert.Null(exception); + } + + [Fact] + public void Long_ThrowIfIsLessThanZero_ShouldNotThrowArgumentOutOfRangeException_IfArgumentIsZero() + { + const int argument = 0; + var exception = Record.Exception(() => { argument.ThrowIfIsLessThanZero(nameof(argument)); }); + Assert.Null(exception); + } + } } \ No newline at end of file diff --git a/src/oehen.arguard.Tests/oehen.arguard.Tests.csproj b/src/oehen.arguard.Tests/oehen.arguard.Tests.csproj index df32e90a..12be38fe 100644 --- a/src/oehen.arguard.Tests/oehen.arguard.Tests.csproj +++ b/src/oehen.arguard.Tests/oehen.arguard.Tests.csproj @@ -1,4 +1,4 @@ - + @@ -12,7 +12,7 @@ Library - netcoreapp3.1;net5.0;net6.0 + net6.0;net48 diff --git a/src/oehen.arguard/Between/ArgumentDecimalBetweenGuard.cs b/src/oehen.arguard/Between/ArgumentDecimalBetweenGuard.cs index 60e377c7..6f64a71a 100644 --- a/src/oehen.arguard/Between/ArgumentDecimalBetweenGuard.cs +++ b/src/oehen.arguard/Between/ArgumentDecimalBetweenGuard.cs @@ -1,41 +1,41 @@ -using System; -using System.Globalization; - -namespace oehen.arguard.Between -{ - /// - /// argument between validator. - /// - public static class ArgumentDecimalBetweenGuard - { - /// - /// Throws an exception if the is between - /// and . - /// - /// Argument value. - /// Start range to compare. - /// End range to compare. - /// Name of the argument. - /// - /// Throws when the argument `decimalArgument` is between 5 and 10. - /// - /// - /// - /// - public static decimal ThrowIfIsBetween(this decimal argument, decimal compareValueStart, decimal compareValueEnd, string nameOfArgument) - { - if (argument > compareValueStart && argument < compareValueEnd) - { - throw new ArgumentOutOfRangeException( - nameOfArgument, - argument, - string.Format(CultureInfo.CurrentCulture, - ArgumentExceptionMessageResourceManager.GetMessage("ThrowIfIsBetween"), - compareValueStart, compareValueEnd)); - } - return argument; - } - } +using System; +using System.Globalization; + +namespace oehen.arguard.Between +{ + /// + /// argument between validator. + /// + public static class ArgumentDecimalBetweenGuard + { + /// + /// Throws an exception if the is between + /// and . + /// + /// Argument value. + /// Start range to compare. + /// End range to compare. + /// Name of the argument. + /// + /// Throws when the argument `decimalArgument` is between 5 and 10. + /// + /// + /// + /// + public static decimal ThrowIfIsBetween(this decimal argument, decimal compareValueStart, decimal compareValueEnd, string nameOfArgument) + { + if (argument > compareValueStart && argument < compareValueEnd) + { + throw new ArgumentOutOfRangeException( + nameOfArgument, + argument, + string.Format(CultureInfo.CurrentCulture, + ArgumentExceptionMessageResourceManager.GetMessage("ThrowIfIsBetween"), + compareValueStart, compareValueEnd)); + } + return argument; + } + } } \ No newline at end of file diff --git a/src/oehen.arguard/oehen.arguard.csproj b/src/oehen.arguard/oehen.arguard.csproj index 40d8fead..10f57240 100644 --- a/src/oehen.arguard/oehen.arguard.csproj +++ b/src/oehen.arguard/oehen.arguard.csproj @@ -1,7 +1,7 @@ - netstandard2.0;netcoreapp3.1;net5.0;net6.0;net8.0 + netstandard2.0;netcoreapp3.1;net5.0;net6.0;net8.0;net472;net48 oehen.arguard en-US false