-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
2 changed files
with
51 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using FluentAssertions; | ||
using System; | ||
using System.Diagnostics; | ||
using bzTorrent.Helpers; | ||
using Xunit; | ||
using bzTorrent.Data; | ||
using bzTorrent.Extensions; | ||
using System.Collections.Generic; | ||
|
||
namespace bzTorrent.Tests.Extensions | ||
{ | ||
public class ExtensionsTests | ||
{ | ||
[Fact] | ||
public void IsNullOrEmptyReturnsTrueForEmptyArray() | ||
{ | ||
Array.Empty<object>().IsNullOrEmpty().Should().BeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void IsNullOrEmptyReturnsFalseForArrayWithObjects() | ||
{ | ||
var array = new List<object>() { new object(), new object(), new object() }; | ||
array.IsNullOrEmpty().Should().BeFalse(); | ||
} | ||
|
||
[Fact] | ||
public void IsNullOrEmptyReturnsTrueForNullCastedToArray() | ||
{ | ||
var nullArray = (object[])null; | ||
nullArray.IsNullOrEmpty().Should().BeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void ThrowIfNullThrowsExceptionForNull() | ||
{ | ||
object x = null; | ||
var ex = Record.Exception(() => x.ThrowIfNull(nameof(x))); | ||
Assert.NotNull(ex); | ||
} | ||
|
||
[Fact] | ||
public void ThrowIfNullDoesNotThrowExceptionForValidObject() | ||
{ | ||
object x = new(); | ||
var ex = Record.Exception(() => x.ThrowIfNull(nameof(x))); | ||
Assert.Null(ex); | ||
} | ||
} | ||
} |
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