-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests) Improve multitargetframework
- Loading branch information
Showing
20 changed files
with
1,025 additions
and
879 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ArgumentNullException>(() => | ||
{ | ||
// 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<ArgumentNullException>(() => | ||
{ | ||
// 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<ArgumentNullException>(() => | ||
{ | ||
// 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<ArgumentNullException>(() => | ||
{ | ||
// 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<ArgumentNullException>(() => | ||
{ | ||
// 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<ArgumentNullException>(() => | ||
{ | ||
// 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); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -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<string> argument = new List<string>(); | ||
var exception = Assert.Throws<ArgumentNullException>(() => | ||
{ | ||
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<string> argument = new List<string> | ||
{ | ||
"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<string> argument = new List<string> | ||
{ | ||
"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<string> argument = new List<string> | ||
{ | ||
"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<string> argument = new List<string> | ||
{ | ||
"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<string> argument = new List<string>(); | ||
var exception = Assert.Throws<ArgumentNullException>(() => | ||
{ | ||
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<string> argument = new List<string> | ||
{ | ||
"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<string> argument = new List<string> | ||
{ | ||
"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<string> argument = new List<string> | ||
{ | ||
"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<string> argument = new List<string> | ||
{ | ||
"entry one", | ||
"entry two", | ||
"entry three" | ||
}; | ||
var result = argument.ThrowIfIsNullOrEmpty(nameof(argument)); | ||
result.Should().BeEquivalentTo(argument); | ||
} | ||
} | ||
} |
Oops, something went wrong.