-
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.
Added tests for update email request
- Loading branch information
Showing
1 changed file
with
73 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using PinguApps.Appwrite.Shared.Requests; | ||
using FluentValidation; | ||
using PinguApps.Appwrite.Shared.Requests; | ||
|
||
namespace PinguApps.Appwrite.Shared.Tests.Requests; | ||
public class UpdateEmailRequestTests | ||
|
@@ -32,4 +33,75 @@ public void Properties_CanBeSet(string email, string password) | |
Assert.Equal(email, request.Email); | ||
Assert.Equal(password, request.Password); | ||
} | ||
|
||
[Theory] | ||
[InlineData("[email protected]", "Password")] | ||
[InlineData("[email protected]", "£$%^&*()")] | ||
public void IsValid_WithValidData_ReturnsTrue(string email, string password) | ||
{ | ||
// Arrange | ||
var request = new UpdateEmailRequest | ||
{ | ||
Email = email, | ||
Password = password | ||
}; | ||
|
||
// Act | ||
var isValid = request.IsValid(); | ||
|
||
// Assert | ||
Assert.True(isValid); | ||
} | ||
|
||
[Theory] | ||
[InlineData("not an email", "Password")] | ||
[InlineData("", "Password")] | ||
[InlineData("[email protected]", "short")] | ||
[InlineData("[email protected]", "")] | ||
public void IsValid_WithInvalidData_ReturnsFalse(string email, string password) | ||
{ | ||
// Arrange | ||
var request = new UpdateEmailRequest | ||
{ | ||
Email = email, | ||
Password = password | ||
}; | ||
|
||
// Act | ||
var isValid = request.IsValid(); | ||
|
||
// Assert | ||
Assert.False(isValid); | ||
} | ||
|
||
[Fact] | ||
public void Validate_WithThrowOnFailuresTrue_ThrowsValidationExceptionOnFailure() | ||
{ | ||
// Arrange | ||
var request = new UpdateEmailRequest | ||
{ | ||
Email = "not an email", | ||
Password = "short" | ||
}; | ||
|
||
// Assert | ||
Assert.Throws<ValidationException>(() => request.Validate(true)); | ||
} | ||
|
||
[Fact] | ||
public void Validate_WithThrowOnFailuresFalse_ReturnsInvalidResultOnFailure() | ||
{ | ||
// Arrange | ||
var request = new UpdateEmailRequest | ||
{ | ||
Email = "not an email", | ||
Password = "short" | ||
}; | ||
|
||
// Act | ||
var result = request.Validate(false); | ||
|
||
// Assert | ||
Assert.False(result.IsValid); | ||
} | ||
} |