From fcf346985f367c462ef7b65ce7d5d2612f7345cc Mon Sep 17 00:00:00 2001 From: Maciej Zieniuk Date: Mon, 25 Nov 2024 20:45:41 +0000 Subject: [PATCH] PM-10564: Sync notification push type separation for notification updates Sync notification push type is now used for both Notification create and update. Renamed the event types to specifically mention the purpose of status for notification status updates. --- src/Core/Enums/PushType.cs | 4 +- .../Commands/CreateNotificationCommand.cs | 2 +- .../CreateNotificationStatusCommand.cs | 2 +- .../MarkNotificationDeletedCommand.cs | 4 +- .../Commands/MarkNotificationReadCommand.cs | 4 +- .../Commands/UpdateNotificationCommand.cs | 2 +- .../NotificationHubPushNotificationService.cs | 16 +- src/Core/Services/IPushNotificationService.cs | 4 +- .../AzureQueuePushNotificationService.cs | 12 +- .../MultiServicePushNotificationService.cs | 8 +- ...NotificationsApiPushNotificationService.cs | 12 +- .../RelayPushNotificationService.cs | 16 +- .../NoopPushNotificationService.cs | 4 +- src/Notifications/HubHelpers.cs | 4 +- .../Commands/CreateNotificationCommandTest.cs | 10 +- .../CreateNotificationStatusCommandTest.cs | 20 ++- .../MarkNotificationDeletedCommandTest.cs | 37 ++++- .../MarkNotificationReadCommandTest.cs | 37 ++++- .../Commands/UpdateNotificationCommandTest.cs | 15 +- ...ficationHubPushNotificationServiceTests.cs | 157 ++++++++---------- .../AzureQueuePushNotificationServiceTests.cs | 18 +- ...ultiServicePushNotificationServiceTests.cs | 17 +- 22 files changed, 221 insertions(+), 184 deletions(-) diff --git a/src/Core/Enums/PushType.cs b/src/Core/Enums/PushType.cs index 5af56e0767..541e2cd072 100644 --- a/src/Core/Enums/PushType.cs +++ b/src/Core/Enums/PushType.cs @@ -26,6 +26,6 @@ public enum PushType : byte SyncOrganizations = 17, - SyncNotificationCreate = 18, - SyncNotificationUpdate = 19 + SyncNotification = 18, + SyncNotificationStatus = 19 } diff --git a/src/Core/NotificationCenter/Commands/CreateNotificationCommand.cs b/src/Core/NotificationCenter/Commands/CreateNotificationCommand.cs index a4cacea1ea..75faba0874 100644 --- a/src/Core/NotificationCenter/Commands/CreateNotificationCommand.cs +++ b/src/Core/NotificationCenter/Commands/CreateNotificationCommand.cs @@ -37,7 +37,7 @@ public class CreateNotificationCommand : ICreateNotificationCommand var newNotification = await _notificationRepository.CreateAsync(notification); - await _pushNotificationService.PushSyncNotificationCreateAsync(newNotification); + await _pushNotificationService.PushSyncNotificationAsync(newNotification); return newNotification; } diff --git a/src/Core/NotificationCenter/Commands/CreateNotificationStatusCommand.cs b/src/Core/NotificationCenter/Commands/CreateNotificationStatusCommand.cs index 8e54a55c5c..b88d29552f 100644 --- a/src/Core/NotificationCenter/Commands/CreateNotificationStatusCommand.cs +++ b/src/Core/NotificationCenter/Commands/CreateNotificationStatusCommand.cs @@ -48,7 +48,7 @@ public class CreateNotificationStatusCommand : ICreateNotificationStatusCommand var newNotificationStatus = await _notificationStatusRepository.CreateAsync(notificationStatus); - await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, newNotificationStatus); + await _pushNotificationService.PushSyncNotificationStatusAsync(notification, newNotificationStatus); return newNotificationStatus; } diff --git a/src/Core/NotificationCenter/Commands/MarkNotificationDeletedCommand.cs b/src/Core/NotificationCenter/Commands/MarkNotificationDeletedCommand.cs index 67d3f8dd4f..70c4444bb8 100644 --- a/src/Core/NotificationCenter/Commands/MarkNotificationDeletedCommand.cs +++ b/src/Core/NotificationCenter/Commands/MarkNotificationDeletedCommand.cs @@ -65,7 +65,7 @@ public class MarkNotificationDeletedCommand : IMarkNotificationDeletedCommand var newNotificationStatus = await _notificationStatusRepository.CreateAsync(notificationStatus); - await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, newNotificationStatus); + await _pushNotificationService.PushSyncNotificationStatusAsync(notification, newNotificationStatus); } else { @@ -76,7 +76,7 @@ public class MarkNotificationDeletedCommand : IMarkNotificationDeletedCommand await _notificationStatusRepository.UpdateAsync(notificationStatus); - await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, notificationStatus); + await _pushNotificationService.PushSyncNotificationStatusAsync(notification, notificationStatus); } } } diff --git a/src/Core/NotificationCenter/Commands/MarkNotificationReadCommand.cs b/src/Core/NotificationCenter/Commands/MarkNotificationReadCommand.cs index 17dc3a2f0a..7068ca2c33 100644 --- a/src/Core/NotificationCenter/Commands/MarkNotificationReadCommand.cs +++ b/src/Core/NotificationCenter/Commands/MarkNotificationReadCommand.cs @@ -65,7 +65,7 @@ public class MarkNotificationReadCommand : IMarkNotificationReadCommand var newNotificationStatus = await _notificationStatusRepository.CreateAsync(notificationStatus); - await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, newNotificationStatus); + await _pushNotificationService.PushSyncNotificationStatusAsync(notification, newNotificationStatus); } else { @@ -76,7 +76,7 @@ public class MarkNotificationReadCommand : IMarkNotificationReadCommand await _notificationStatusRepository.UpdateAsync(notificationStatus); - await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, notificationStatus); + await _pushNotificationService.PushSyncNotificationStatusAsync(notification, notificationStatus); } } } diff --git a/src/Core/NotificationCenter/Commands/UpdateNotificationCommand.cs b/src/Core/NotificationCenter/Commands/UpdateNotificationCommand.cs index ad2b2bc4a0..0b0a2141c0 100644 --- a/src/Core/NotificationCenter/Commands/UpdateNotificationCommand.cs +++ b/src/Core/NotificationCenter/Commands/UpdateNotificationCommand.cs @@ -48,6 +48,6 @@ public class UpdateNotificationCommand : IUpdateNotificationCommand await _notificationRepository.ReplaceAsync(notification); - await _pushNotificationService.PushSyncNotificationUpdateAsync(notification, null); + await _pushNotificationService.PushSyncNotificationAsync(notification); } } diff --git a/src/Core/NotificationHub/NotificationHubPushNotificationService.cs b/src/Core/NotificationHub/NotificationHubPushNotificationService.cs index 90030ad209..617a74363b 100644 --- a/src/Core/NotificationHub/NotificationHubPushNotificationService.cs +++ b/src/Core/NotificationHub/NotificationHubPushNotificationService.cs @@ -182,7 +182,7 @@ public class NotificationHubPushNotificationService : IPushNotificationService await PushAuthRequestAsync(authRequest, PushType.AuthRequestResponse); } - public async Task PushSyncNotificationCreateAsync(Notification notification) + public async Task PushSyncNotificationAsync(Notification notification) { var message = new SyncNotificationPushNotification { @@ -195,17 +195,17 @@ public class NotificationHubPushNotificationService : IPushNotificationService if (notification.UserId.HasValue) { - await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotificationCreate, message, true, + await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotification, message, true, notification.ClientType); } else if (notification.OrganizationId.HasValue) { - await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotificationCreate, message, + await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotification, message, true, notification.ClientType); } } - public async Task PushSyncNotificationUpdateAsync(Notification notification, NotificationStatus? notificationStatus) + public async Task PushSyncNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus) { var message = new SyncNotificationPushNotification { @@ -214,18 +214,18 @@ public class NotificationHubPushNotificationService : IPushNotificationService OrganizationId = notification.OrganizationId, ClientType = notification.ClientType, RevisionDate = notification.RevisionDate, - ReadDate = notificationStatus?.ReadDate, - DeletedDate = notificationStatus?.DeletedDate + ReadDate = notificationStatus.ReadDate, + DeletedDate = notificationStatus.DeletedDate }; if (notification.UserId.HasValue) { - await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotificationUpdate, message, true, + await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotificationStatus, message, true, notification.ClientType); } else if (notification.OrganizationId.HasValue) { - await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotificationUpdate, message, + await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotificationStatus, message, true, notification.ClientType); } } diff --git a/src/Core/Services/IPushNotificationService.cs b/src/Core/Services/IPushNotificationService.cs index fe26e9a843..3659a69fe8 100644 --- a/src/Core/Services/IPushNotificationService.cs +++ b/src/Core/Services/IPushNotificationService.cs @@ -24,8 +24,8 @@ public interface IPushNotificationService Task PushSyncSendCreateAsync(Send send); Task PushSyncSendUpdateAsync(Send send); Task PushSyncSendDeleteAsync(Send send); - Task PushSyncNotificationCreateAsync(Notification notification); - Task PushSyncNotificationUpdateAsync(Notification notification, NotificationStatus? notificationStatus); + Task PushSyncNotificationAsync(Notification notification); + Task PushSyncNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus); Task PushAuthRequestAsync(AuthRequest authRequest); Task PushAuthRequestResponseAsync(AuthRequest authRequest); diff --git a/src/Core/Services/Implementations/AzureQueuePushNotificationService.cs b/src/Core/Services/Implementations/AzureQueuePushNotificationService.cs index 3dd93e5d2d..d041888fec 100644 --- a/src/Core/Services/Implementations/AzureQueuePushNotificationService.cs +++ b/src/Core/Services/Implementations/AzureQueuePushNotificationService.cs @@ -165,7 +165,7 @@ public class AzureQueuePushNotificationService : IPushNotificationService await PushSendAsync(send, PushType.SyncSendDelete); } - public async Task PushSyncNotificationCreateAsync(Notification notification) + public async Task PushSyncNotificationAsync(Notification notification) { var message = new SyncNotificationPushNotification { @@ -176,10 +176,10 @@ public class AzureQueuePushNotificationService : IPushNotificationService RevisionDate = notification.RevisionDate }; - await SendMessageAsync(PushType.SyncNotificationCreate, message, true); + await SendMessageAsync(PushType.SyncNotification, message, true); } - public async Task PushSyncNotificationUpdateAsync(Notification notification, NotificationStatus? notificationStatus) + public async Task PushSyncNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus) { var message = new SyncNotificationPushNotification { @@ -188,11 +188,11 @@ public class AzureQueuePushNotificationService : IPushNotificationService OrganizationId = notification.OrganizationId, ClientType = notification.ClientType, RevisionDate = notification.RevisionDate, - ReadDate = notificationStatus?.ReadDate, - DeletedDate = notificationStatus?.DeletedDate + ReadDate = notificationStatus.ReadDate, + DeletedDate = notificationStatus.DeletedDate }; - await SendMessageAsync(PushType.SyncNotificationUpdate, message, true); + await SendMessageAsync(PushType.SyncNotificationStatus, message, true); } private async Task PushSendAsync(Send send, PushType type) diff --git a/src/Core/Services/Implementations/MultiServicePushNotificationService.cs b/src/Core/Services/Implementations/MultiServicePushNotificationService.cs index 4d266a538a..36e9197116 100644 --- a/src/Core/Services/Implementations/MultiServicePushNotificationService.cs +++ b/src/Core/Services/Implementations/MultiServicePushNotificationService.cs @@ -146,15 +146,15 @@ public class MultiServicePushNotificationService : IPushNotificationService return Task.FromResult(0); } - public Task PushSyncNotificationCreateAsync(Notification notification) + public Task PushSyncNotificationAsync(Notification notification) { - PushToServices((s) => s.PushSyncNotificationCreateAsync(notification)); + PushToServices((s) => s.PushSyncNotificationAsync(notification)); return Task.CompletedTask; } - public Task PushSyncNotificationUpdateAsync(Notification notification, NotificationStatus? notificationStatus) + public Task PushSyncNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus) { - PushToServices((s) => s.PushSyncNotificationUpdateAsync(notification, notificationStatus)); + PushToServices((s) => s.PushSyncNotificationStatusAsync(notification, notificationStatus)); return Task.CompletedTask; } diff --git a/src/Core/Services/Implementations/NotificationsApiPushNotificationService.cs b/src/Core/Services/Implementations/NotificationsApiPushNotificationService.cs index dd70a72539..7edb5602b8 100644 --- a/src/Core/Services/Implementations/NotificationsApiPushNotificationService.cs +++ b/src/Core/Services/Implementations/NotificationsApiPushNotificationService.cs @@ -172,7 +172,7 @@ public class NotificationsApiPushNotificationService : BaseIdentityClientService await PushSendAsync(send, PushType.SyncSendDelete); } - public async Task PushSyncNotificationCreateAsync(Notification notification) + public async Task PushSyncNotificationAsync(Notification notification) { var message = new SyncNotificationPushNotification { @@ -183,10 +183,10 @@ public class NotificationsApiPushNotificationService : BaseIdentityClientService RevisionDate = notification.RevisionDate }; - await SendMessageAsync(PushType.SyncNotificationCreate, message, true); + await SendMessageAsync(PushType.SyncNotification, message, true); } - public async Task PushSyncNotificationUpdateAsync(Notification notification, NotificationStatus? notificationStatus) + public async Task PushSyncNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus) { var message = new SyncNotificationPushNotification { @@ -195,11 +195,11 @@ public class NotificationsApiPushNotificationService : BaseIdentityClientService OrganizationId = notification.OrganizationId, ClientType = notification.ClientType, RevisionDate = notification.RevisionDate, - ReadDate = notificationStatus?.ReadDate, - DeletedDate = notificationStatus?.DeletedDate + ReadDate = notificationStatus.ReadDate, + DeletedDate = notificationStatus.DeletedDate }; - await SendMessageAsync(PushType.SyncNotificationUpdate, message, true); + await SendMessageAsync(PushType.SyncNotificationStatus, message, true); } private async Task PushSendAsync(Send send, PushType type) diff --git a/src/Core/Services/Implementations/RelayPushNotificationService.cs b/src/Core/Services/Implementations/RelayPushNotificationService.cs index 6c1600da48..2aec38dca4 100644 --- a/src/Core/Services/Implementations/RelayPushNotificationService.cs +++ b/src/Core/Services/Implementations/RelayPushNotificationService.cs @@ -190,7 +190,7 @@ public class RelayPushNotificationService : BaseIdentityClientService, IPushNoti await SendPayloadToUserAsync(authRequest.UserId, type, message, true); } - public async Task PushSyncNotificationCreateAsync(Notification notification) + public async Task PushSyncNotificationAsync(Notification notification) { var message = new SyncNotificationPushNotification { @@ -203,17 +203,17 @@ public class RelayPushNotificationService : BaseIdentityClientService, IPushNoti if (notification.UserId.HasValue) { - await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotificationCreate, message, true, + await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotification, message, true, notification.ClientType); } else if (notification.OrganizationId.HasValue) { - await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotificationCreate, message, + await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotification, message, true, notification.ClientType); } } - public async Task PushSyncNotificationUpdateAsync(Notification notification, NotificationStatus? notificationStatus) + public async Task PushSyncNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus) { var message = new SyncNotificationPushNotification { @@ -222,18 +222,18 @@ public class RelayPushNotificationService : BaseIdentityClientService, IPushNoti OrganizationId = notification.OrganizationId, ClientType = notification.ClientType, RevisionDate = notification.RevisionDate, - ReadDate = notificationStatus?.ReadDate, - DeletedDate = notificationStatus?.DeletedDate + ReadDate = notificationStatus.ReadDate, + DeletedDate = notificationStatus.DeletedDate }; if (notification.UserId.HasValue) { - await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotificationUpdate, message, true, + await SendPayloadToUserAsync(notification.UserId.Value, PushType.SyncNotificationStatus, message, true, notification.ClientType); } else if (notification.OrganizationId.HasValue) { - await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotificationUpdate, message, + await SendPayloadToOrganizationAsync(notification.OrganizationId.Value, PushType.SyncNotificationStatus, message, true, notification.ClientType); } } diff --git a/src/Core/Services/NoopImplementations/NoopPushNotificationService.cs b/src/Core/Services/NoopImplementations/NoopPushNotificationService.cs index 548c6a159e..9f4994c5bc 100644 --- a/src/Core/Services/NoopImplementations/NoopPushNotificationService.cs +++ b/src/Core/Services/NoopImplementations/NoopPushNotificationService.cs @@ -106,7 +106,7 @@ public class NoopPushNotificationService : IPushNotificationService return Task.FromResult(0); } - public Task PushSyncNotificationCreateAsync(Notification notification) => Task.CompletedTask; + public Task PushSyncNotificationAsync(Notification notification) => Task.CompletedTask; - public Task PushSyncNotificationUpdateAsync(Notification notification, NotificationStatus? notificationStatus) => Task.CompletedTask; + public Task PushSyncNotificationStatusAsync(Notification notification, NotificationStatus notificationStatus) => Task.CompletedTask; } diff --git a/src/Notifications/HubHelpers.cs b/src/Notifications/HubHelpers.cs index 7047db0734..0f32529196 100644 --- a/src/Notifications/HubHelpers.cs +++ b/src/Notifications/HubHelpers.cs @@ -89,8 +89,8 @@ public static class HubHelpers await hubContext.Clients.User(authRequestNotification.Payload.UserId.ToString()) .SendAsync(_receiveMessageMethod, authRequestNotification, cancellationToken); break; - case PushType.SyncNotificationCreate: - case PushType.SyncNotificationUpdate: + case PushType.SyncNotification: + case PushType.SyncNotificationStatus: var syncNotification = JsonSerializer.Deserialize>( notificationJson, _deserializerOptions); diff --git a/test/Core.Test/NotificationCenter/Commands/CreateNotificationCommandTest.cs b/test/Core.Test/NotificationCenter/Commands/CreateNotificationCommandTest.cs index 05e18b4385..eaa15a02d7 100644 --- a/test/Core.Test/NotificationCenter/Commands/CreateNotificationCommandTest.cs +++ b/test/Core.Test/NotificationCenter/Commands/CreateNotificationCommandTest.cs @@ -43,7 +43,10 @@ public class CreateNotificationCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.CreateAsync(notification)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationCreateAsync(Arg.Any()); + .PushSyncNotificationAsync(Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); } [Theory] @@ -61,6 +64,9 @@ public class CreateNotificationCommandTest Assert.Equal(notification.CreationDate, notification.RevisionDate); await sutProvider.GetDependency() .Received(1) - .PushSyncNotificationCreateAsync(newNotification); + .PushSyncNotificationAsync(newNotification); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); } } diff --git a/test/Core.Test/NotificationCenter/Commands/CreateNotificationStatusCommandTest.cs b/test/Core.Test/NotificationCenter/Commands/CreateNotificationStatusCommandTest.cs index 80ad31ead2..7eedbfd8ca 100644 --- a/test/Core.Test/NotificationCenter/Commands/CreateNotificationStatusCommandTest.cs +++ b/test/Core.Test/NotificationCenter/Commands/CreateNotificationStatusCommandTest.cs @@ -53,7 +53,10 @@ public class CreateNotificationStatusCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.CreateAsync(notificationStatus)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationUpdateAsync(Arg.Any(), Arg.Any()); + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } [Theory] @@ -67,7 +70,10 @@ public class CreateNotificationStatusCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.CreateAsync(notificationStatus)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationUpdateAsync(Arg.Any(), Arg.Any()); + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } [Theory] @@ -81,7 +87,10 @@ public class CreateNotificationStatusCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.CreateAsync(notificationStatus)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationUpdateAsync(Arg.Any(), Arg.Any()); + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } [Theory] @@ -97,6 +106,9 @@ public class CreateNotificationStatusCommandTest Assert.Equal(notificationStatus, newNotificationStatus); await sutProvider.GetDependency() .Received(1) - .PushSyncNotificationUpdateAsync(notification, notificationStatus); + .PushSyncNotificationStatusAsync(notification, notificationStatus); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } } diff --git a/test/Core.Test/NotificationCenter/Commands/MarkNotificationDeletedCommandTest.cs b/test/Core.Test/NotificationCenter/Commands/MarkNotificationDeletedCommandTest.cs index 15a2807e55..3d698074da 100644 --- a/test/Core.Test/NotificationCenter/Commands/MarkNotificationDeletedCommandTest.cs +++ b/test/Core.Test/NotificationCenter/Commands/MarkNotificationDeletedCommandTest.cs @@ -66,7 +66,10 @@ public class MarkNotificationDeletedCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.MarkDeletedAsync(notificationId)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationUpdateAsync(Arg.Any(), Arg.Any()); + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } [Theory] @@ -80,7 +83,10 @@ public class MarkNotificationDeletedCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.MarkDeletedAsync(notificationId)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationUpdateAsync(Arg.Any(), Arg.Any()); + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } [Theory] @@ -95,7 +101,10 @@ public class MarkNotificationDeletedCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.MarkDeletedAsync(notificationId)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationUpdateAsync(Arg.Any(), Arg.Any()); + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } [Theory] @@ -110,7 +119,10 @@ public class MarkNotificationDeletedCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.MarkDeletedAsync(notificationId)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationUpdateAsync(Arg.Any(), Arg.Any()); + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } [Theory] @@ -125,7 +137,10 @@ public class MarkNotificationDeletedCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.MarkDeletedAsync(notificationId)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationUpdateAsync(Arg.Any(), Arg.Any()); + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } [Theory] @@ -149,8 +164,11 @@ public class MarkNotificationDeletedCommandTest .CreateAsync(Arg.Do(ns => AssertNotificationStatus(expectedNotificationStatus, ns))); await sutProvider.GetDependency() .Received(1) - .PushSyncNotificationUpdateAsync(notification, + .PushSyncNotificationStatusAsync(notification, Arg.Do(ns => AssertNotificationStatus(expectedNotificationStatus, ns))); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } [Theory] @@ -167,8 +185,11 @@ public class MarkNotificationDeletedCommandTest .UpdateAsync(Arg.Do(ns => AssertNotificationStatus(notificationStatus, ns))); await sutProvider.GetDependency() .Received(1) - .PushSyncNotificationUpdateAsync(notification, - Arg.Do(ns => AssertNotificationStatus(notificationStatus, ns))); + .PushSyncNotificationStatusAsync(notification, + Arg.Do(ns => AssertNotificationStatus(notificationStatus, ns))); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } private static void AssertNotificationStatus(NotificationStatus expectedNotificationStatus, diff --git a/test/Core.Test/NotificationCenter/Commands/MarkNotificationReadCommandTest.cs b/test/Core.Test/NotificationCenter/Commands/MarkNotificationReadCommandTest.cs index f6b0c58803..999f95c402 100644 --- a/test/Core.Test/NotificationCenter/Commands/MarkNotificationReadCommandTest.cs +++ b/test/Core.Test/NotificationCenter/Commands/MarkNotificationReadCommandTest.cs @@ -66,7 +66,10 @@ public class MarkNotificationReadCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.MarkReadAsync(notificationId)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationUpdateAsync(Arg.Any(), Arg.Any()); + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } [Theory] @@ -80,7 +83,10 @@ public class MarkNotificationReadCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.MarkReadAsync(notificationId)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationUpdateAsync(Arg.Any(), Arg.Any()); + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } [Theory] @@ -95,7 +101,10 @@ public class MarkNotificationReadCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.MarkReadAsync(notificationId)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationUpdateAsync(Arg.Any(), Arg.Any()); + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } [Theory] @@ -110,7 +119,10 @@ public class MarkNotificationReadCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.MarkReadAsync(notificationId)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationUpdateAsync(Arg.Any(), Arg.Any()); + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } [Theory] @@ -125,7 +137,10 @@ public class MarkNotificationReadCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.MarkReadAsync(notificationId)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationUpdateAsync(Arg.Any(), Arg.Any()); + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } [Theory] @@ -149,8 +164,11 @@ public class MarkNotificationReadCommandTest .CreateAsync(Arg.Do(ns => AssertNotificationStatus(expectedNotificationStatus, ns))); await sutProvider.GetDependency() .Received(1) - .PushSyncNotificationUpdateAsync(notification, + .PushSyncNotificationStatusAsync(notification, Arg.Do(ns => AssertNotificationStatus(expectedNotificationStatus, ns))); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } [Theory] @@ -167,8 +185,11 @@ public class MarkNotificationReadCommandTest .UpdateAsync(Arg.Do(ns => AssertNotificationStatus(notificationStatus, ns))); await sutProvider.GetDependency() .Received(1) - .PushSyncNotificationUpdateAsync(notification, - Arg.Do(ns => AssertNotificationStatus(notificationStatus, ns))); + .PushSyncNotificationStatusAsync(notification, + Arg.Do(ns => AssertNotificationStatus(notificationStatus, ns))); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationAsync(Arg.Any()); } private static void AssertNotificationStatus(NotificationStatus expectedNotificationStatus, diff --git a/test/Core.Test/NotificationCenter/Commands/UpdateNotificationCommandTest.cs b/test/Core.Test/NotificationCenter/Commands/UpdateNotificationCommandTest.cs index d45233b6d1..a36ac55d7e 100644 --- a/test/Core.Test/NotificationCenter/Commands/UpdateNotificationCommandTest.cs +++ b/test/Core.Test/NotificationCenter/Commands/UpdateNotificationCommandTest.cs @@ -48,7 +48,10 @@ public class UpdateNotificationCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.UpdateAsync(notification)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationUpdateAsync(Arg.Any(), Arg.Any()); + .PushSyncNotificationAsync(Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); } [Theory] @@ -62,7 +65,10 @@ public class UpdateNotificationCommandTest await Assert.ThrowsAsync(() => sutProvider.Sut.UpdateAsync(notification)); await sutProvider.GetDependency() .Received(0) - .PushSyncNotificationUpdateAsync(Arg.Any(), Arg.Any()); + .PushSyncNotificationAsync(Arg.Any()); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); } [Theory] @@ -100,6 +106,9 @@ public class UpdateNotificationCommandTest DateTime.UtcNow - n.RevisionDate < TimeSpan.FromMinutes(1))); await sutProvider.GetDependency() .Received(1) - .PushSyncNotificationUpdateAsync(notification, null); + .PushSyncNotificationAsync(notification); + await sutProvider.GetDependency() + .Received(0) + .PushSyncNotificationStatusAsync(Arg.Any(), Arg.Any()); } } diff --git a/test/Core.Test/NotificationHub/NotificationHubPushNotificationServiceTests.cs b/test/Core.Test/NotificationHub/NotificationHubPushNotificationServiceTests.cs index e9b5557d46..728f2810df 100644 --- a/test/Core.Test/NotificationHub/NotificationHubPushNotificationServiceTests.cs +++ b/test/Core.Test/NotificationHub/NotificationHubPushNotificationServiceTests.cs @@ -21,10 +21,10 @@ public class NotificationHubPushNotificationServiceTests [Theory] [BitAutoData] [NotificationCustomize] - public async Task PushSyncNotificationCreateAsync_Global_NotSent( + public async Task PushSyncNotificationAsync_Global_NotSent( SutProvider sutProvider, Notification notification) { - await sutProvider.Sut.PushSyncNotificationCreateAsync(notification); + await sutProvider.Sut.PushSyncNotificationAsync(notification); await sutProvider.GetDependency() .Received(0) @@ -40,7 +40,7 @@ public class NotificationHubPushNotificationServiceTests [BitAutoData(false)] [BitAutoData(true)] [NotificationCustomize(false)] - public async Task PushSyncNotificationCreateAsync_UserIdProvidedClientTypeAll_SentToUser( + public async Task PushSyncNotificationAsync_UserIdProvidedClientTypeAll_SentToUser( bool organizationIdNull, SutProvider sutProvider, Notification notification) { @@ -52,9 +52,9 @@ public class NotificationHubPushNotificationServiceTests notification.ClientType = ClientType.All; var expectedSyncNotification = ToSyncNotificationPushNotification(notification, null); - await sutProvider.Sut.PushSyncNotificationCreateAsync(notification); + await sutProvider.Sut.PushSyncNotificationAsync(notification); - await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationCreate, + await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotification, expectedSyncNotification, $"(template:payload_userId:{notification.UserId})"); await sutProvider.GetDependency() @@ -68,7 +68,7 @@ public class NotificationHubPushNotificationServiceTests [BitAutoData(ClientType.Web)] [BitAutoData(ClientType.Mobile)] [NotificationCustomize(false)] - public async Task PushSyncNotificationCreateAsync_UserIdProvidedOrganizationIdNullClientTypeNotAll_SentToUser( + public async Task PushSyncNotificationAsync_UserIdProvidedOrganizationIdNullClientTypeNotAll_SentToUser( ClientType clientType, SutProvider sutProvider, Notification notification) { @@ -76,9 +76,9 @@ public class NotificationHubPushNotificationServiceTests notification.ClientType = clientType; var expectedSyncNotification = ToSyncNotificationPushNotification(notification, null); - await sutProvider.Sut.PushSyncNotificationCreateAsync(notification); + await sutProvider.Sut.PushSyncNotificationAsync(notification); - await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationCreate, + await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotification, expectedSyncNotification, $"(template:payload_userId:{notification.UserId} && clientType:{clientType})"); await sutProvider.GetDependency() @@ -92,16 +92,16 @@ public class NotificationHubPushNotificationServiceTests [BitAutoData(ClientType.Web)] [BitAutoData(ClientType.Mobile)] [NotificationCustomize(false)] - public async Task PushSyncNotificationCreateAsync_UserIdProvidedOrganizationIdProvidedClientTypeNotAll_SentToUser( + public async Task PushSyncNotificationAsync_UserIdProvidedOrganizationIdProvidedClientTypeNotAll_SentToUser( ClientType clientType, SutProvider sutProvider, Notification notification) { notification.ClientType = clientType; var expectedSyncNotification = ToSyncNotificationPushNotification(notification, null); - await sutProvider.Sut.PushSyncNotificationCreateAsync(notification); + await sutProvider.Sut.PushSyncNotificationAsync(notification); - await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationCreate, + await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotification, expectedSyncNotification, $"(template:payload_userId:{notification.UserId} && clientType:{clientType})"); await sutProvider.GetDependency() @@ -112,16 +112,16 @@ public class NotificationHubPushNotificationServiceTests [Theory] [BitAutoData] [NotificationCustomize(false)] - public async Task PushSyncNotificationCreateAsync_UserIdNullOrganizationIdProvidedClientTypeAll_SentToOrganization( + public async Task PushSyncNotificationAsync_UserIdNullOrganizationIdProvidedClientTypeAll_SentToOrganization( SutProvider sutProvider, Notification notification) { notification.UserId = null; notification.ClientType = ClientType.All; var expectedSyncNotification = ToSyncNotificationPushNotification(notification, null); - await sutProvider.Sut.PushSyncNotificationCreateAsync(notification); + await sutProvider.Sut.PushSyncNotificationAsync(notification); - await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationCreate, + await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotification, expectedSyncNotification, $"(template:payload && organizationId:{notification.OrganizationId})"); await sutProvider.GetDependency() @@ -135,18 +135,17 @@ public class NotificationHubPushNotificationServiceTests [BitAutoData(ClientType.Web)] [BitAutoData(ClientType.Mobile)] [NotificationCustomize(false)] - public async Task - PushSyncNotificationCreateAsync_UserIdNullOrganizationIdProvidedClientTypeNotAll_SentToOrganization( - ClientType clientType, SutProvider sutProvider, - Notification notification) + public async Task PushSyncNotificationAsync_UserIdNullOrganizationIdProvidedClientTypeNotAll_SentToOrganization( + ClientType clientType, SutProvider sutProvider, + Notification notification) { notification.UserId = null; notification.ClientType = clientType; var expectedSyncNotification = ToSyncNotificationPushNotification(notification, null); - await sutProvider.Sut.PushSyncNotificationCreateAsync(notification); + await sutProvider.Sut.PushSyncNotificationAsync(notification); - await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationCreate, + await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotification, expectedSyncNotification, $"(template:payload && organizationId:{notification.OrganizationId} && clientType:{clientType})"); await sutProvider.GetDependency() @@ -155,15 +154,13 @@ public class NotificationHubPushNotificationServiceTests } [Theory] - [BitAutoData(false)] - [BitAutoData(true)] + [BitAutoData] [NotificationCustomize] - public async Task PushSyncNotificationUpdateAsync_Global_NotSent(bool notificationStatusNull, + public async Task PushSyncNotificationStatusAsync_Global_NotSent( SutProvider sutProvider, Notification notification, NotificationStatus notificationStatus) { - await sutProvider.Sut.PushSyncNotificationUpdateAsync(notification, - notificationStatusNull ? null : notificationStatus); + await sutProvider.Sut.PushSyncNotificationStatusAsync(notification, notificationStatus); await sutProvider.GetDependency() .Received(0) @@ -176,14 +173,11 @@ public class NotificationHubPushNotificationServiceTests } [Theory] - [BitAutoData(false, false)] - [BitAutoData(false, true)] - [BitAutoData(true, false)] - [BitAutoData(true, true)] + [BitAutoData(false)] + [BitAutoData(true)] [NotificationCustomize(false)] - public async Task PushSyncNotificationUpdateAsync_UserIdProvidedClientTypeAll_SentToUser( - bool organizationIdNull, bool notificationStatusNull, - SutProvider sutProvider, + public async Task PushSyncNotificationStatusAsync_UserIdProvidedClientTypeAll_SentToUser( + bool organizationIdNull, SutProvider sutProvider, Notification notification, NotificationStatus notificationStatus) { if (organizationIdNull) @@ -192,12 +186,11 @@ public class NotificationHubPushNotificationServiceTests } notification.ClientType = ClientType.All; - var expectedNotificationStatus = notificationStatusNull ? null : notificationStatus; - var expectedSyncNotification = ToSyncNotificationPushNotification(notification, expectedNotificationStatus); + var expectedSyncNotification = ToSyncNotificationPushNotification(notification, notificationStatus); - await sutProvider.Sut.PushSyncNotificationUpdateAsync(notification, expectedNotificationStatus); + await sutProvider.Sut.PushSyncNotificationStatusAsync(notification, notificationStatus); - await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationUpdate, + await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationStatus, expectedSyncNotification, $"(template:payload_userId:{notification.UserId})"); await sutProvider.GetDependency() @@ -206,28 +199,22 @@ public class NotificationHubPushNotificationServiceTests } [Theory] - [BitAutoData(false, ClientType.Browser)] - [BitAutoData(false, ClientType.Desktop)] - [BitAutoData(false, ClientType.Web)] - [BitAutoData(false, ClientType.Mobile)] - [BitAutoData(true, ClientType.Browser)] - [BitAutoData(true, ClientType.Desktop)] - [BitAutoData(true, ClientType.Web)] - [BitAutoData(true, ClientType.Mobile)] + [BitAutoData(ClientType.Browser)] + [BitAutoData(ClientType.Desktop)] + [BitAutoData(ClientType.Web)] + [BitAutoData(ClientType.Mobile)] [NotificationCustomize(false)] - public async Task PushSyncNotificationUpdateAsync_UserIdProvidedOrganizationIdNullClientTypeNotAll_SentToUser( - bool notificationStatusNull, ClientType clientType, - SutProvider sutProvider, Notification notification, - NotificationStatus notificationStatus) + public async Task PushSyncNotificationStatusAsync_UserIdProvidedOrganizationIdNullClientTypeNotAll_SentToUser( + ClientType clientType, SutProvider sutProvider, + Notification notification, NotificationStatus notificationStatus) { notification.OrganizationId = null; notification.ClientType = clientType; - var expectedNotificationStatus = notificationStatusNull ? null : notificationStatus; - var expectedSyncNotification = ToSyncNotificationPushNotification(notification, expectedNotificationStatus); + var expectedSyncNotification = ToSyncNotificationPushNotification(notification, notificationStatus); - await sutProvider.Sut.PushSyncNotificationUpdateAsync(notification, expectedNotificationStatus); + await sutProvider.Sut.PushSyncNotificationStatusAsync(notification, notificationStatus); - await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationUpdate, + await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationStatus, expectedSyncNotification, $"(template:payload_userId:{notification.UserId} && clientType:{clientType})"); await sutProvider.GetDependency() @@ -236,27 +223,21 @@ public class NotificationHubPushNotificationServiceTests } [Theory] - [BitAutoData(false, ClientType.Browser)] - [BitAutoData(false, ClientType.Desktop)] - [BitAutoData(false, ClientType.Web)] - [BitAutoData(false, ClientType.Mobile)] - [BitAutoData(true, ClientType.Browser)] - [BitAutoData(true, ClientType.Desktop)] - [BitAutoData(true, ClientType.Web)] - [BitAutoData(true, ClientType.Mobile)] + [BitAutoData(ClientType.Browser)] + [BitAutoData(ClientType.Desktop)] + [BitAutoData(ClientType.Web)] + [BitAutoData(ClientType.Mobile)] [NotificationCustomize(false)] - public async Task PushSyncNotificationUpdateAsync_UserIdProvidedOrganizationIdProvidedClientTypeNotAll_SentToUser( - bool notificationStatusNull, ClientType clientType, - SutProvider sutProvider, + public async Task PushSyncNotificationStatusAsync_UserIdProvidedOrganizationIdProvidedClientTypeNotAll_SentToUser( + ClientType clientType, SutProvider sutProvider, Notification notification, NotificationStatus notificationStatus) { notification.ClientType = clientType; - var expectedNotificationStatus = notificationStatusNull ? null : notificationStatus; - var expectedSyncNotification = ToSyncNotificationPushNotification(notification, expectedNotificationStatus); + var expectedSyncNotification = ToSyncNotificationPushNotification(notification, notificationStatus); - await sutProvider.Sut.PushSyncNotificationUpdateAsync(notification, expectedNotificationStatus); + await sutProvider.Sut.PushSyncNotificationStatusAsync(notification, notificationStatus); - await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationUpdate, + await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationStatus, expectedSyncNotification, $"(template:payload_userId:{notification.UserId} && clientType:{clientType})"); await sutProvider.GetDependency() @@ -265,21 +246,19 @@ public class NotificationHubPushNotificationServiceTests } [Theory] - [BitAutoData(false)] - [BitAutoData(true)] + [BitAutoData] [NotificationCustomize(false)] - public async Task PushSyncNotificationUpdateAsync_UserIdNullOrganizationIdProvidedClientTypeAll_SentToOrganization( - bool notificationStatusNull, SutProvider sutProvider, - Notification notification, NotificationStatus notificationStatus) + public async Task PushSyncNotificationStatusAsync_UserIdNullOrganizationIdProvidedClientTypeAll_SentToOrganization( + SutProvider sutProvider, Notification notification, + NotificationStatus notificationStatus) { notification.UserId = null; notification.ClientType = ClientType.All; - var expectedNotificationStatus = notificationStatusNull ? null : notificationStatus; - var expectedSyncNotification = ToSyncNotificationPushNotification(notification, expectedNotificationStatus); + var expectedSyncNotification = ToSyncNotificationPushNotification(notification, notificationStatus); - await sutProvider.Sut.PushSyncNotificationUpdateAsync(notification, expectedNotificationStatus); + await sutProvider.Sut.PushSyncNotificationStatusAsync(notification, notificationStatus); - await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationUpdate, + await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationStatus, expectedSyncNotification, $"(template:payload && organizationId:{notification.OrganizationId})"); await sutProvider.GetDependency() @@ -288,29 +267,23 @@ public class NotificationHubPushNotificationServiceTests } [Theory] - [BitAutoData(false, ClientType.Browser)] - [BitAutoData(false, ClientType.Desktop)] - [BitAutoData(false, ClientType.Web)] - [BitAutoData(false, ClientType.Mobile)] - [BitAutoData(true, ClientType.Browser)] - [BitAutoData(true, ClientType.Desktop)] - [BitAutoData(true, ClientType.Web)] - [BitAutoData(true, ClientType.Mobile)] + [BitAutoData(ClientType.Browser)] + [BitAutoData(ClientType.Desktop)] + [BitAutoData(ClientType.Web)] + [BitAutoData(ClientType.Mobile)] [NotificationCustomize(false)] public async Task - PushSyncNotificationUpdateAsync_UserIdNullOrganizationIdProvidedClientTypeNotAll_SentToOrganization( - bool notificationStatusNull, ClientType clientType, - SutProvider sutProvider, Notification notification, - NotificationStatus notificationStatus) + PushSyncNotificationStatusAsync_UserIdNullOrganizationIdProvidedClientTypeNotAll_SentToOrganization( + ClientType clientType, SutProvider sutProvider, + Notification notification, NotificationStatus notificationStatus) { notification.UserId = null; notification.ClientType = clientType; - var expectedNotificationStatus = notificationStatusNull ? null : notificationStatus; - var expectedSyncNotification = ToSyncNotificationPushNotification(notification, expectedNotificationStatus); + var expectedSyncNotification = ToSyncNotificationPushNotification(notification, notificationStatus); - await sutProvider.Sut.PushSyncNotificationUpdateAsync(notification, expectedNotificationStatus); + await sutProvider.Sut.PushSyncNotificationStatusAsync(notification, notificationStatus); - await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationUpdate, + await AssertSendTemplateNotificationAsync(sutProvider, PushType.SyncNotificationStatus, expectedSyncNotification, $"(template:payload && organizationId:{notification.OrganizationId} && clientType:{clientType})"); await sutProvider.GetDependency() diff --git a/test/Core.Test/Services/AzureQueuePushNotificationServiceTests.cs b/test/Core.Test/Services/AzureQueuePushNotificationServiceTests.cs index 3907d34c50..e702a267e6 100644 --- a/test/Core.Test/Services/AzureQueuePushNotificationServiceTests.cs +++ b/test/Core.Test/Services/AzureQueuePushNotificationServiceTests.cs @@ -25,7 +25,7 @@ public class AzureQueuePushNotificationServiceTests [BitAutoData] [NotificationCustomize] [CurrentContextCustomize] - public async Task PushSyncNotificationCreateAsync_Notification_Sent( + public async Task PushSyncNotificationAsync_Notification_Sent( SutProvider sutProvider, Notification notification, Guid deviceIdentifier, ICurrentContext currentContext) { @@ -33,35 +33,33 @@ public class AzureQueuePushNotificationServiceTests sutProvider.GetDependency().HttpContext!.RequestServices .GetService(Arg.Any()).Returns(currentContext); - await sutProvider.Sut.PushSyncNotificationCreateAsync(notification); + await sutProvider.Sut.PushSyncNotificationAsync(notification); await sutProvider.GetDependency().Received(1) .SendMessageAsync(Arg.Is(message => - MatchMessage(PushType.SyncNotificationCreate, message, new SyncNotificationEquals(notification, null), + MatchMessage(PushType.SyncNotification, message, new SyncNotificationEquals(notification, null), deviceIdentifier.ToString()))); } [Theory] - [BitAutoData(false)] - [BitAutoData(true)] + [BitAutoData] [NotificationCustomize] [NotificationStatusCustomize] [CurrentContextCustomize] - public async Task PushSyncNotificationUpdateAsync_Notification_Sent(bool notificationStatusNull, + public async Task PushSyncNotificationStatusAsync_Notification_Sent( SutProvider sutProvider, Notification notification, Guid deviceIdentifier, ICurrentContext currentContext, NotificationStatus notificationStatus) { - var expectedNotificationStatus = notificationStatusNull ? null : notificationStatus; currentContext.DeviceIdentifier.Returns(deviceIdentifier.ToString()); sutProvider.GetDependency().HttpContext!.RequestServices .GetService(Arg.Any()).Returns(currentContext); - await sutProvider.Sut.PushSyncNotificationUpdateAsync(notification, expectedNotificationStatus); + await sutProvider.Sut.PushSyncNotificationStatusAsync(notification, notificationStatus); await sutProvider.GetDependency().Received(1) .SendMessageAsync(Arg.Is(message => - MatchMessage(PushType.SyncNotificationUpdate, message, - new SyncNotificationEquals(notification, expectedNotificationStatus), + MatchMessage(PushType.SyncNotificationStatus, message, + new SyncNotificationEquals(notification, notificationStatus), deviceIdentifier.ToString()))); } diff --git a/test/Core.Test/Services/MultiServicePushNotificationServiceTests.cs b/test/Core.Test/Services/MultiServicePushNotificationServiceTests.cs index bd8bfeeba4..1181f88300 100644 --- a/test/Core.Test/Services/MultiServicePushNotificationServiceTests.cs +++ b/test/Core.Test/Services/MultiServicePushNotificationServiceTests.cs @@ -16,34 +16,31 @@ public class MultiServicePushNotificationServiceTests [Theory] [BitAutoData] [NotificationCustomize] - public async Task PushSyncNotificationCreateAsync_Notification_Sent( + public async Task PushSyncNotificationAsync_Notification_Sent( SutProvider sutProvider, Notification notification) { - await sutProvider.Sut.PushSyncNotificationCreateAsync(notification); + await sutProvider.Sut.PushSyncNotificationAsync(notification); await sutProvider.GetDependency>() .First() .Received(1) - .PushSyncNotificationCreateAsync(notification); + .PushSyncNotificationAsync(notification); } [Theory] - [BitAutoData(false)] - [BitAutoData(true)] + [BitAutoData] [NotificationCustomize] [NotificationStatusCustomize] - public async Task PushSyncNotificationUpdateAsync_Notification_Sent(bool notificationStatusNull, + public async Task PushSyncNotificationStatusAsync_Notification_Sent( SutProvider sutProvider, Notification notification, NotificationStatus notificationStatus) { - await sutProvider.Sut.PushSyncNotificationUpdateAsync(notification, - notificationStatusNull ? null : notificationStatus); + await sutProvider.Sut.PushSyncNotificationStatusAsync(notification, notificationStatus); - var expectedNotificationStatus = notificationStatusNull ? null : notificationStatus; await sutProvider.GetDependency>() .First() .Received(1) - .PushSyncNotificationUpdateAsync(notification, expectedNotificationStatus); + .PushSyncNotificationStatusAsync(notification, notificationStatus); } [Theory]