-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 changed file
with
106 additions
and
0 deletions.
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
tests/PinguApps.Appwrite.Shared.Tests/Requests/CreatePasswordRecoveryTests.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,106 @@ | ||
using FluentValidation; | ||
using PinguApps.Appwrite.Shared.Requests; | ||
|
||
namespace PinguApps.Appwrite.Shared.Tests.Requests; | ||
public class CreatePasswordRecoveryTests | ||
{ | ||
[Fact] | ||
public void Constructor_InitializesWithExpectedValues() | ||
{ | ||
// Arrange & Act | ||
var request = new CreatePasswordRecoveryRequest(); | ||
|
||
// Assert | ||
Assert.Equal(string.Empty, request.Email); | ||
Assert.Equal(string.Empty, request.Url); | ||
} | ||
|
||
[Fact] | ||
public void Properties_CanBeSet() | ||
{ | ||
var url = "https://localhost:1234/abc"; | ||
var email = "[email protected]"; | ||
|
||
// Arrange | ||
var request = new CreatePasswordRecoveryRequest(); | ||
|
||
// Act | ||
request.Url = url; | ||
request.Email = email; | ||
|
||
// Assert | ||
Assert.Equal(url, request.Url); | ||
Assert.Equal(email, request.Email); | ||
} | ||
|
||
[Fact] | ||
public void IsValid_WithValidData_ReturnsTrue() | ||
{ | ||
// Arrange | ||
var request = new CreatePasswordRecoveryRequest | ||
{ | ||
Email = "[email protected]", | ||
Url = "https://localhost:1234/abc" | ||
}; | ||
|
||
// Act | ||
var isValid = request.IsValid(); | ||
|
||
// Assert | ||
Assert.True(isValid); | ||
} | ||
|
||
[Theory] | ||
[InlineData(null, "https://localhost:1234/abc")] | ||
[InlineData("", "https://localhost:1234/abc")] | ||
[InlineData("Not an email", "https://localhost:1234/abc")] | ||
[InlineData("[email protected]", null)] | ||
[InlineData("[email protected]", "")] | ||
[InlineData("[email protected]", "Not a URL")] | ||
public void IsValid_WithInvalidData_ReturnsFalse(string? email, string? url) | ||
{ | ||
// Arrange | ||
var request = new CreatePasswordRecoveryRequest | ||
{ | ||
Email = email!, | ||
Url = url! | ||
}; | ||
|
||
// Act | ||
var isValid = request.IsValid(); | ||
|
||
// Assert | ||
Assert.False(isValid); | ||
} | ||
|
||
[Fact] | ||
public void Validate_WithThrowOnFailuresTrue_ThrowsValidationExceptionOnFailure() | ||
{ | ||
// Arrange | ||
var request = new CreatePasswordRecoveryRequest | ||
{ | ||
Email = "", | ||
Url = "" | ||
}; | ||
|
||
// Assert | ||
Assert.Throws<ValidationException>(() => request.Validate(true)); | ||
} | ||
|
||
[Fact] | ||
public void Validate_WithThrowOnFailuresFalse_ReturnsInvalidResultOnFailure() | ||
{ | ||
// Arrange | ||
var request = new CreatePasswordRecoveryRequest | ||
{ | ||
Email = "", | ||
Url = "" | ||
}; | ||
|
||
// Act | ||
var result = request.Validate(false); | ||
|
||
// Assert | ||
Assert.False(result.IsValid); | ||
} | ||
} |