Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added missing '.' #344

Merged
merged 5 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/Altinn.Notifications.Core/Services/GetOrderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@ namespace Altinn.Notifications.Core.Services;
public class GetOrderService : IGetOrderService
{
private readonly IOrderRepository _repo;
private readonly Dictionary<OrderProcessingStatus, string> _descriptions;
private readonly static Dictionary<OrderProcessingStatus, string> _descriptions = new()
{
{ OrderProcessingStatus.Registered, "Order has been registered and is awaiting requested send time before processing." },
{ OrderProcessingStatus.Processing, "Order processing is ongoing. Notifications are being generated." },
{ OrderProcessingStatus.Completed, "Order processing is completed. All notifications have been generated." },
};

/// <summary>
/// Initializes a new instance of the <see cref="GetOrderService"/> class.
/// </summary>
public GetOrderService(IOrderRepository repo)
{
_repo = repo;
_descriptions = new()
{
{ OrderProcessingStatus.Registered, "Order has been registered and is awaiting requested send time before processing" },
{ OrderProcessingStatus.Processing, "Order processing is ongoing. Notifications are being generated." },
{ OrderProcessingStatus.Completed, "Order processing is completed. All notifications have been generated." },
};
}

/// <inheritdoc/>
Expand Down Expand Up @@ -59,7 +58,15 @@ public GetOrderService(IOrderRepository repo)
return (null, new ServiceError(404));
}

order.ProcessingStatus.StatusDescription = _descriptions[order.ProcessingStatus.Status];
order.ProcessingStatus.StatusDescription = GetStatusDescription(order.ProcessingStatus.Status);
return (order, null);
}

/// <summary>
/// Gets the English description of the <see cref="OrderProcessingStatus"/>"
/// </summary>
internal static string GetStatusDescription(OrderProcessingStatus result)
{
return _descriptions[result];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public async Task GetWithStatusById_SingleMatchInDbAndOneEmail_ReturnsOk()
{
LastUpdate = persistedOrder.Created,
Status = "Registered",
StatusDescription = "Order has been registered and is awaiting requested send time before processing"
StatusDescription = "Order has been registered and is awaiting requested send time before processing."
},
NotificationsStatusSummary = new NotificationsStatusSummaryExt()
{
Expand Down Expand Up @@ -123,7 +123,7 @@ public async Task GetWithStatusById_SingleMatchInDb_ReturnsOk()
{
LastUpdate = persistedOrder.Created,
Status = "Registered",
StatusDescription = "Order has been registered and is awaiting requested send time before processing"
StatusDescription = "Order has been registered and is awaiting requested send time before processing."
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;

using Altinn.Notifications.Core.Enums;
using Altinn.Notifications.Core.Models.Orders;
using Altinn.Notifications.Core.Repository.Interfaces;
using Altinn.Notifications.Core.Services;
Expand Down Expand Up @@ -110,6 +111,26 @@ public async Task GetOrdersBySendersReference_GetOrdersBySendersReferenceCalledI
Assert.Null(actuallError);
}

[Theory]
[InlineData(OrderProcessingStatus.Registered, "Order has been registered and is awaiting requested send time before processing.")]
[InlineData(OrderProcessingStatus.Processing, "Order processing is ongoing. Notifications are being generated.")]
[InlineData(OrderProcessingStatus.Completed, "Order processing is completed. All notifications have been generated.")]
public void GetStatusDescription_ExpectedDescription(OrderProcessingStatus status, string expected)
{
string actual = GetOrderService.GetStatusDescription(status);
Assert.Equal(expected, actual);
}

[Fact]
public void GetStatusDescription_AllResultTypesHaveDescriptions()
{
foreach (OrderProcessingStatus statusType in Enum.GetValues(typeof(OrderProcessingStatus)))
{
string statusDescription = GetOrderService.GetStatusDescription(statusType);
Assert.NotEmpty(statusDescription);
}
}

private static GetOrderService GetTestService(IOrderRepository? repo = null)
{
if (repo == null)
Expand Down
Loading