-
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.
- Loading branch information
1 parent
46f13b2
commit f361657
Showing
1 changed file
with
29 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,19 +28,19 @@ public async Task ProcessOrder_NotificationServiceCalledOnceForEachRecipient() | |
{ | ||
Id = Guid.NewGuid(), | ||
NotificationChannel = NotificationChannel.Email, | ||
Recipients = new List<Recipient>() | ||
{ | ||
Recipients = | ||
[ | ||
new() | ||
{ | ||
OrganizationNumber = "123456", | ||
AddressInfo = [new EmailAddressPoint("[email protected]")] | ||
OrganizationNumber = "123456", | ||
AddressInfo = [new EmailAddressPoint("[email protected]")] | ||
}, | ||
new() | ||
{ | ||
OrganizationNumber = "654321", | ||
AddressInfo = [new EmailAddressPoint("[email protected]")] | ||
OrganizationNumber = "654321", | ||
AddressInfo = [new EmailAddressPoint("[email protected]")] | ||
} | ||
} | ||
] | ||
}; | ||
|
||
var serviceMock = new Mock<IEmailNotificationService>(); | ||
|
@@ -59,28 +59,30 @@ public async Task ProcessOrder_NotificationServiceCalledOnceForEachRecipient() | |
public async Task ProcessOrder_ExpectedInputToNotificationService() | ||
{ | ||
// Arrange | ||
Guid orderId = Guid.NewGuid(); | ||
DateTime requested = DateTime.UtcNow; | ||
Guid orderId = Guid.NewGuid(); | ||
|
||
var order = new NotificationOrder() | ||
{ | ||
Id = orderId, | ||
NotificationChannel = NotificationChannel.Email, | ||
RequestedSendTime = requested, | ||
Recipients = new List<Recipient>() | ||
{ | ||
new(new List<IAddressPoint>() { new EmailAddressPoint("[email protected]") }, organizationNumber: "skd-orgno") | ||
} | ||
Recipients = | ||
[ | ||
new([new EmailAddressPoint("[email protected]")], organizationNumber: "skd-orgno") | ||
] | ||
}; | ||
|
||
List<EmailAddressPoint> expectedEmailAddressPoints = [new("[email protected]")]; | ||
EmailRecipient expectedEmailRecipient = new() | ||
{ | ||
OrganizationNumber = "skd-orgno" | ||
}; | ||
EmailRecipient expectedEmailRecipient = new() { OrganizationNumber = "skd-orgno" }; | ||
|
||
var serviceMock = new Mock<IEmailNotificationService>(); | ||
serviceMock.Setup(s => s.CreateNotification(It.IsAny<Guid>(), It.Is<DateTime>(d => d.Equals(requested)), It.Is<List<EmailAddressPoint>>(r => AssertUtils.AreEquivalent(expectedEmailAddressPoints, r)), It.Is<EmailRecipient>(e => AssertUtils.AreEquivalent(expectedEmailRecipient, e)), It.IsAny<bool>())); | ||
serviceMock.Setup(s => s.CreateNotification( | ||
It.IsAny<Guid>(), | ||
It.Is<DateTime>(d => d.Equals(requested)), | ||
It.Is<List<EmailAddressPoint>>(r => AssertUtils.AreEquivalent(expectedEmailAddressPoints, r)), | ||
It.Is<EmailRecipient>(e => AssertUtils.AreEquivalent(expectedEmailRecipient, e)), | ||
It.IsAny<bool>())); | ||
|
||
var service = GetTestService(emailService: serviceMock.Object); | ||
|
||
|
@@ -101,16 +103,6 @@ public async Task ProcessOrder_NotificationServiceThrowsException_RepositoryNotC | |
Recipients = | ||
[ | ||
new() | ||
{ | ||
AddressInfo = | ||
[ | ||
new EmailAddressPoint() | ||
{ | ||
AddressType = AddressType.Email, | ||
EmailAddress = "[email protected]" | ||
} | ||
] | ||
} | ||
] | ||
}; | ||
|
||
|
@@ -179,13 +171,13 @@ public async Task ProcessOrderRetry_ServiceCalledIfRecipientNotInDatabase() | |
{ | ||
Id = Guid.NewGuid(), | ||
NotificationChannel = NotificationChannel.Email, | ||
Recipients = new List<Recipient>() | ||
{ | ||
Recipients = | ||
[ | ||
new(), | ||
new(new List<IAddressPoint>() { new EmailAddressPoint("[email protected]") }, nationalIdentityNumber: "enduser-nin"), | ||
new(new List<IAddressPoint>() { new EmailAddressPoint("[email protected]") }, organizationNumber : "skd-orgNo"), | ||
new(new List<IAddressPoint>() { new EmailAddressPoint("[email protected]") }) | ||
} | ||
new([new EmailAddressPoint("[email protected]")], nationalIdentityNumber: "enduser-nin"), | ||
new([new EmailAddressPoint("[email protected]")], organizationNumber : "skd-orgNo"), | ||
new([new EmailAddressPoint("[email protected]")]) | ||
] | ||
}; | ||
|
||
var serviceMock = new Mock<IEmailNotificationService>(); | ||
|
@@ -209,10 +201,10 @@ public async Task ProcessOrderRetry_ServiceCalledIfRecipientNotInDatabase() | |
} | ||
|
||
private static EmailOrderProcessingService GetTestService( | ||
IEmailNotificationRepository? emailRepo = null, | ||
IEmailNotificationService? emailService = null, | ||
IContactPointService? contactPointService = null, | ||
IKeywordsService? keywordsService = null) | ||
IEmailNotificationRepository? emailRepo = null, | ||
IEmailNotificationService? emailService = null, | ||
IContactPointService? contactPointService = null, | ||
IKeywordsService? keywordsService = null) | ||
{ | ||
if (emailRepo == null) | ||
{ | ||
|