From c43f95e20a1197c01fd358163e35aa4f6468bfb6 Mon Sep 17 00:00:00 2001 From: "Khan Mohammad R." Date: Mon, 27 Nov 2023 11:47:29 +0100 Subject: [PATCH] Test added for the modification to convert Local to UTC --- .../TestingMappers/OrderMapperTests.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/Altinn.Notifications.Tests/Notifications/TestingMappers/OrderMapperTests.cs b/test/Altinn.Notifications.Tests/Notifications/TestingMappers/OrderMapperTests.cs index a3e332cc4..dcfa9dff4 100644 --- a/test/Altinn.Notifications.Tests/Notifications/TestingMappers/OrderMapperTests.cs +++ b/test/Altinn.Notifications.Tests/Notifications/TestingMappers/OrderMapperTests.cs @@ -140,6 +140,42 @@ public void MapToOrderRequest_RecipientsProvided_AreEquivalent() Assert.Equivalent(expected, actual, true); } + [Fact] + public void MapToOrderRequest_SendTimeLocalConvertedToUtc_AreEquivalent() + { + DateTime sendTime = DateTime.Now; // Setting the time in Local time zone + + // Arrange + EmailNotificationOrderRequestExt orderRequestExt = new() + { + Body = "email-body", + ContentType = EmailContentTypeExt.Html, + RequestedSendTime = sendTime, // Local time zone + Subject = "email-subject" + }; + + NotificationOrderRequest expected = new() + { + Creator = new Creator("ttd"), + Templates = new List() + { + new EmailTemplate( + string.Empty, + "email-subject", + "email-body", + EmailContentType.Html) + }, + RequestedSendTime = sendTime.ToUniversalTime(), // Expecting the time in UTC time zone + NotificationChannel = NotificationChannel.Email + }; + + // Act + var actual = orderRequestExt.MapToOrderRequest("ttd"); + + // Assert + Assert.Equivalent(expected, actual, true); + } + [Fact] public void MapToNotificationOrderWithStatusExt_EmailStatusProvided_AreEquivalent() {