Skip to content

Commit

Permalink
Update OrderMapper.cs (#588)
Browse files Browse the repository at this point in the history
* Update OrderMapper.cs

* added unit test

* Update test/Altinn.Notifications.Tests/Notifications/TestingMappers/OrderMapperTests.cs
  • Loading branch information
acn-sbuad authored Aug 13, 2024
1 parent 0fef6c9 commit f72b021
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Altinn.Notifications/Mappers/OrderMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static NotificationOrderRequest MapToOrderRequest(this NotificationOrderR
creator,
templateList,
extRequest.RequestedSendTime.ToUniversalTime(),
NotificationChannel.Email,
(NotificationChannel)extRequest.NotificationChannel!,
recipients,
extRequest.IgnoreReservation,
extRequest.ResourceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,72 @@ public void ForSmsMapToOrderRequest_SendTimeLocalConvertedToUtc_AreEquivalent()
Assert.Equivalent(expected, actual, true);
}

[Theory]
[InlineData(NotificationChannelExt.Email, NotificationChannel.Email)]
[InlineData(NotificationChannelExt.EmailPreferred, NotificationChannel.EmailPreferred)]
[InlineData(NotificationChannelExt.Sms, NotificationChannel.Sms)]
[InlineData(NotificationChannelExt.SmsPreferred, NotificationChannel.SmsPreferred)]
public void MapToOrderRequest_AreEquivalent(NotificationChannelExt extChannel, NotificationChannel expectedChannel)
{
// Arrange
DateTime sendTime = DateTime.UtcNow;

NotificationOrderRequestExt ext = new()
{
NotificationChannel = extChannel,
EmailTemplate = new()
{
Subject = "email-subject",
Body = "email-body",
ContentType = EmailContentTypeExt.Html
},
SmsTemplate = new()
{
Body = "sms-body",
},
Recipients = new List<RecipientExt>() { new RecipientExt() { EmailAddress = "recipient1@domain.com" }, new RecipientExt() { NationalIdentityNumber = "123456" } },
SendersReference = "senders-reference",
RequestedSendTime = sendTime,
ConditionEndpoint = new Uri("https://vg.no"),
IgnoreReservation = true,
ResourceId = "urn:altinn:resource:test"
};

NotificationOrderRequest expected = new()
{
SendersReference = "senders-reference",
Creator = new Creator("ttd"),
Templates = new List<INotificationTemplate>()
{
new EmailTemplate(
string.Empty,
"email-subject",
"email-body",
EmailContentType.Html),
new SmsTemplate(
string.Empty,
"sms-body")
},
RequestedSendTime = sendTime,
Recipients = new List<Recipient>()
{
new Recipient() { AddressInfo = new List<IAddressPoint>() { new EmailAddressPoint("recipient1@domain.com") } },
new Recipient() { NationalIdentityNumber = "123456" }
},
ConditionEndpoint = new Uri("https://vg.no"),
IgnoreReservation = true,
ResourceId = "urn:altinn:resource:test"
};

expected.NotificationChannel = expectedChannel;

// Act
var actual = ext.MapToOrderRequest("ttd");

// Assert
Assert.Equivalent(expected, actual);
}

[Fact]
public void MapToNotificationOrderWithStatusExt_EmailStatusProvided_AreEquivalent()
{
Expand Down

0 comments on commit f72b021

Please sign in to comment.