Skip to content

Commit

Permalink
check return value
Browse files Browse the repository at this point in the history
  • Loading branch information
martindybal committed Nov 19, 2022
1 parent 59e5b46 commit 0bc83a5
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dybal.Utils.Guards;
using Newtonsoft.Json.Linq;
using Xunit;

namespace Tests.Dybal.Utils.Guards.ArgumentGuard;
Expand All @@ -12,7 +13,7 @@ public void NotThrows_When_null()
Guid? value = null;

// Act
Guard.Argument(value).NotDefaultIfHasValue();
value = Guard.Argument(value).NotDefaultIfHasValue();

// Assert
// doesn't throw any exception
Expand All @@ -25,7 +26,7 @@ public void NotThrows_When_not_empty_guid()
Guid? value = Guid.NewGuid();

// Act
Guard.Argument(value).NotDefaultIfHasValue();
value = Guard.Argument(value).NotDefaultIfHasValue();

// Assert
// doesn't throw any exception
Expand All @@ -38,7 +39,7 @@ public void NotThrows_When_not_default_int()
int? value = 1;

// Act
Guard.Argument(value).NotDefaultIfHasValue();
value = Guard.Argument(value).NotDefaultIfHasValue();

// Assert
// doesn't throw any exception
Expand All @@ -52,7 +53,7 @@ public void Throw_ArgumentException_When_empty_guid()

void Act()
{
Guard.Argument(defaultValue).NotDefaultIfHasValue();
defaultValue = Guard.Argument(defaultValue).NotDefaultIfHasValue();
}

// Assert
Expand All @@ -68,7 +69,7 @@ public void Throw_ArgumentException_When_default_int()

void Act()
{
Guard.Argument(defaultValue).NotDefaultIfHasValue();
defaultValue = Guard.Argument(defaultValue).NotDefaultIfHasValue();
}

// Assert
Expand All @@ -85,7 +86,7 @@ public void Throw_ArgumentException_with_custom_message_When_was_used()

void Act()
{
Guard.Argument(defaultValue).NotDefaultIfHasValue(customMessage);
defaultValue = Guard.Argument(defaultValue).NotDefaultIfHasValue(customMessage);
}

// Assert
Expand All @@ -102,7 +103,7 @@ public void Throw_CustomException_When_Throws_was_used()
void Act()
{
ThrowHelper.TryRegister((paramName, message) => new CustomException(paramName, message));
Guard.Argument(defaultValue).Throws<CustomException>().NotDefaultIfHasValue();
defaultValue = Guard.Argument(defaultValue).Throws<CustomException>().NotDefaultIfHasValue();
}

// Assert
Expand Down

0 comments on commit 0bc83a5

Please sign in to comment.