< Summary

Information
Class: ArturRios.Util.Test.Assertion.CustomAssert
Assembly: ArturRios.Util.Test
File(s): D:\Repositories\dotnet-test-util\src\Assertion\CustomAssert.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 36
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage
100%
Covered methods: 6
Fully covered methods: 6
Total methods: 6
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
NullOrEmpty(...)100%22100%
NotNullOrEmpty(...)100%22100%
NullOrEmpty(...)100%11100%
NotNullOrEmpty(...)100%11100%
NullOrWhiteSpace(...)100%11100%
NotNullOrWhiteSpace(...)100%11100%

File(s)

D:\Repositories\dotnet-test-util\src\Assertion\CustomAssert.cs

#LineLine coverage
 1using System.Collections;
 2using ArturRios.Extensions;
 3using Xunit;
 4
 5namespace ArturRios.Util.Test.Assertion;
 6
 7/// <summary>
 8/// Extra xUnit-style assertions for the null/empty checks that come up most often in tests.
 9/// Each method throws a <c>Xunit.Sdk.XunitException</c> when the condition is not met, exactly like <see cref="Assert"/
 10/// </summary>
 11public static class CustomAssert
 12{
 13    /// <summary>Asserts that <paramref name="collection"/> is <c>null</c> or contains no elements.</summary>
 14    /// <param name="collection">The collection to check.</param>
 315    public static void NullOrEmpty(IEnumerable? collection) => Assert.True(collection is null || collection.IsEmpty());
 16
 17    /// <summary>Asserts that <paramref name="collection"/> is not <c>null</c> and contains at least one element.</summa
 18    /// <param name="collection">The collection to check.</param>
 319    public static void NotNullOrEmpty(IEnumerable? collection) => Assert.True(collection is not null && collection.IsNot
 20
 21    /// <summary>Asserts that <paramref name="string"/> is <c>null</c> or the empty string.</summary>
 22    /// <param name="string">The string to check.</param>
 323    public static void NullOrEmpty(string? @string) => Assert.True(string.IsNullOrEmpty(@string));
 24
 25    /// <summary>Asserts that <paramref name="string"/> is not <c>null</c> and not the empty string.</summary>
 26    /// <param name="string">The string to check.</param>
 327    public static void NotNullOrEmpty(string? @string) => Assert.False(string.IsNullOrEmpty(@string));
 28
 29    /// <summary>Asserts that <paramref name="string"/> is <c>null</c>, empty, or consists only of white-space character
 30    /// <param name="string">The string to check.</param>
 431    public static void NullOrWhiteSpace(string? @string) => Assert.True(string.IsNullOrWhiteSpace(@string));
 32
 33    /// <summary>Asserts that <paramref name="string"/> contains at least one non-white-space character.</summary>
 34    /// <param name="string">The string to check.</param>
 435    public static void NotNullOrWhiteSpace(string? @string) => Assert.False(string.IsNullOrWhiteSpace(@string));
 36}