-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validating
requestedSendTime
to check if it has zone specified or n…
…ot (#308) * Introduced method to check if requestedSendTime is without zone * Implemented validator with HasTimeZone method * Implemented the conditional predicate with anonymous function * Tests added for time zone validation * Error message updated for the requestedSendTime zone error * Error message updated in the corrsponding tests for the changes * Modification to convert the time zone from Local to UTC * Test added for the modification to convert Local to UTC
- Loading branch information
Showing
4 changed files
with
90 additions
and
3 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
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 |
---|---|---|
|
@@ -66,6 +66,55 @@ public void Validate_EmailNotDefinedForRecipient_ReturnFalse() | |
Assert.Contains(actual.Errors, a => a.ErrorMessage.Equals("A valid email address must be provided for all recipients.")); | ||
} | ||
|
||
[Fact] | ||
public void Validate_SendTimeHasLocalZone_ReturnsTrue() | ||
{ | ||
var order = new EmailNotificationOrderRequestExt() | ||
{ | ||
Subject = "This is an email subject", | ||
Recipients = new List<RecipientExt>() { new RecipientExt() { EmailAddress = "[email protected]" } }, | ||
Body = "This is an email body", | ||
RequestedSendTime = DateTime.Now | ||
}; | ||
|
||
var actual = _validator.Validate(order); | ||
|
||
Assert.True(actual.IsValid); | ||
} | ||
|
||
[Fact] | ||
public void Validate_SendTimeHasUtcZone_ReturnsTrue() | ||
{ | ||
var order = new EmailNotificationOrderRequestExt() | ||
{ | ||
Subject = "This is an email subject", | ||
Recipients = new List<RecipientExt>() { new RecipientExt() { EmailAddress = "[email protected]" } }, | ||
Body = "This is an email body", | ||
RequestedSendTime = DateTime.UtcNow | ||
}; | ||
|
||
var actual = _validator.Validate(order); | ||
|
||
Assert.True(actual.IsValid); | ||
} | ||
|
||
[Fact] | ||
public void Validate_SendTimeHasNoZone_ReturnsFalse() | ||
{ | ||
var order = new EmailNotificationOrderRequestExt() | ||
{ | ||
Subject = "This is an email subject", | ||
Recipients = new List<RecipientExt>() { new RecipientExt() { EmailAddress = "[email protected]" } }, | ||
Body = "This is an email body", | ||
RequestedSendTime = new DateTime(2023, 06, 16, 08, 50, 00, DateTimeKind.Unspecified) | ||
}; | ||
|
||
var actual = _validator.Validate(order); | ||
|
||
Assert.False(actual.IsValid); | ||
Assert.Contains(actual.Errors, a => a.ErrorMessage.Equals("The requested send time value must have specified a time zone.")); | ||
} | ||
|
||
[Fact] | ||
public void Validate_SendTimePassed_ReturnsFalse() | ||
{ | ||
|