-
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.
Merge pull request #68 from BoBoBaSs84/feature/add-some-null-checks
feat: add some null checks
- Loading branch information
Showing
15 changed files
with
154 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace BB84.Extensions; | ||
|
||
public static partial class BooleanExtensions | ||
{ | ||
/// <summary> | ||
/// Indicates whether the specified boolean is null. | ||
/// </summary> | ||
/// <param name="value">The boolean value to test.</param> | ||
/// <returns><see langword="true"/> if the <paramref name="value"/> | ||
/// is <see langword="null"/>, otherwise <see langword="false"/>.</returns> | ||
public static bool IsNull(this bool? value) | ||
=> value.HasValue.Equals(false); | ||
} |
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,13 @@ | ||
namespace BB84.Extensions; | ||
|
||
public static partial class ByteExtensions | ||
{ | ||
/// <summary> | ||
/// Indicates whether the specified byte array is null. | ||
/// </summary> | ||
/// <param name="value">The byte array value to test.</param> | ||
/// <returns><see langword="true"/> if the <paramref name="value"/> | ||
/// is <see langword="null"/>, otherwise <see langword="false"/>.</returns> | ||
public static bool IsNull(this byte[]? value) | ||
=> value is null; | ||
} |
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,13 @@ | ||
namespace BB84.Extensions; | ||
|
||
public static partial class FloatExtensions | ||
{ | ||
/// <summary> | ||
/// Indicates whether the specified float is null. | ||
/// </summary> | ||
/// <param name="value">The float value to test.</param> | ||
/// <returns><see langword="true"/> if the <paramref name="value"/> | ||
/// is <see langword="null"/>, otherwise <see langword="false"/>.</returns> | ||
public static bool IsNull(this float? value) | ||
=> value.HasValue.Equals(false); | ||
} |
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,7 @@ | ||
namespace BB84.Extensions; | ||
|
||
/// <summary> | ||
/// The float extensions class. | ||
/// </summary> | ||
public static partial class FloatExtensions | ||
{ } |
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,13 @@ | ||
namespace BB84.Extensions; | ||
|
||
public static partial class IntegerExtensions | ||
{ | ||
/// <summary> | ||
/// Indicates whether the specified integer is null. | ||
/// </summary> | ||
/// <param name="value">The integer value to test.</param> | ||
/// <returns><see langword="true"/> if the <paramref name="value"/> | ||
/// is <see langword="null"/>, otherwise <see langword="false"/>.</returns> | ||
public static bool IsNull(this int? value) | ||
=> value.HasValue.Equals(false); | ||
} |
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
12 changes: 12 additions & 0 deletions
12
tests/BB84.ExtensionsTests/BooleanExtensionsTests.IsFalse.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,12 @@ | ||
using BB84.Extensions; | ||
|
||
namespace BB84.ExtensionsTests; | ||
|
||
public partial class BooleanExtensionsTests | ||
{ | ||
[DataTestMethod] | ||
[DataRow(true, false)] | ||
[DataRow(false, true)] | ||
public void IsFalseTest(bool value, bool expected) | ||
=> Assert.AreEqual(expected, value.IsFalse()); | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/BB84.ExtensionsTests/BooleanExtensionsTests.IsNull.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,13 @@ | ||
using BB84.Extensions; | ||
|
||
namespace BB84.ExtensionsTests; | ||
|
||
public partial class BooleanExtensionsTests | ||
{ | ||
[DataTestMethod] | ||
[DataRow(true, false)] | ||
[DataRow(false, false)] | ||
[DataRow(null, true)] | ||
public void IsNullTest(bool? value, bool expected) | ||
=> Assert.AreEqual(expected, value.IsNull()); | ||
} |
12 changes: 12 additions & 0 deletions
12
tests/BB84.ExtensionsTests/BooleanExtensionsTests.IsTrue.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,12 @@ | ||
using BB84.Extensions; | ||
|
||
namespace BB84.ExtensionsTests; | ||
|
||
public partial class BooleanExtensionsTests | ||
{ | ||
[DataTestMethod] | ||
[DataRow(true, true)] | ||
[DataRow(false, false)] | ||
public void IsTrueTest(bool value, bool expected) | ||
=> Assert.AreEqual(expected, value.IsTrue()); | ||
} |
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,27 +1,5 @@ | ||
using BB84.Extensions; | ||
|
||
namespace BB84.ExtensionsTests; | ||
namespace BB84.ExtensionsTests; | ||
|
||
[TestClass] | ||
public class BooleanExtensionsTests | ||
{ | ||
[TestMethod] | ||
public void IsTrueTest() | ||
{ | ||
bool value = true; | ||
|
||
bool result = value.IsTrue(); | ||
|
||
Assert.IsTrue(result); | ||
} | ||
|
||
[TestMethod] | ||
public void IsFalseTest() | ||
{ | ||
bool value = false; | ||
|
||
bool result = value.IsFalse(); | ||
|
||
Assert.IsTrue(result); | ||
} | ||
} | ||
public partial class BooleanExtensionsTests | ||
{ } |
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,14 @@ | ||
using BB84.Extensions; | ||
|
||
namespace BB84.ExtensionsTests; | ||
|
||
public partial class ByteExtensionsTests | ||
{ | ||
[DataTestMethod] | ||
[DataRow(new byte[] { 0 }, false)] | ||
[DataRow(null, true)] | ||
public void IsNullTest(byte[]? value, bool expected) | ||
{ | ||
Assert.AreEqual(expected, value.IsNull()); | ||
} | ||
} |
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,12 @@ | ||
using BB84.Extensions; | ||
|
||
namespace BB84.ExtensionsTests; | ||
|
||
public partial class FloatExtensionsTests | ||
{ | ||
[DataTestMethod] | ||
[DataRow(1.67f, false)] | ||
[DataRow(null, true)] | ||
public void IsNullTest(float? value, bool expected) | ||
=> Assert.AreEqual(expected, value.IsNull()); | ||
} |
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,5 @@ | ||
namespace BB84.ExtensionsTests; | ||
|
||
[TestClass] | ||
public partial class FloatExtensionsTests | ||
{ } |
12 changes: 12 additions & 0 deletions
12
tests/BB84.ExtensionsTests/IntegerExtensionsTests.IsNull.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,12 @@ | ||
using BB84.Extensions; | ||
|
||
namespace BB84.ExtensionsTests; | ||
|
||
public sealed partial class IntegerExtensionsTests | ||
{ | ||
[DataTestMethod] | ||
[DataRow(1, false)] | ||
[DataRow(null, true)] | ||
public void IsNullTest(int? value, bool expected) | ||
=> Assert.AreEqual(expected, value.IsNull()); | ||
} |