-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
300 additions
and
26 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
src/oehen.arguard.Tests/LessThan/ArgumentDecimalLessOrEqualThanZeroGuardTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace oehen.arguard | ||
{ | ||
[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<ArgumentOutOfRangeException>(() => | ||
{ | ||
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<ArgumentOutOfRangeException>(() => | ||
{ | ||
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); | ||
} | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
src/oehen.arguard.Tests/LessThan/ArgumentDecimalLessThanGuardTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace oehen.arguard | ||
{ | ||
[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<ArgumentOutOfRangeException>(() => | ||
{ | ||
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<ArgumentOutOfRangeException>(() => | ||
{ | ||
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); | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/oehen.arguard.Tests/LessThan/ArgumentDecimalLessThanZeroGuardTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace oehen.arguard | ||
{ | ||
[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<ArgumentOutOfRangeException>(() => | ||
{ | ||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.