public void WithNoNotificationsToSend_Send_DoesNotSendTheNotification()
        {
            var builder = new PushNotificationCoordinatorBuilder();
            var push    = builder.Build();

            push.Send();
            builder.AssetSendsNotifications(0);
        }
        public void WithNewNotificationsToSend_Send_AddsToSentRepository()
        {
            var builder =
                new PushNotificationCoordinatorBuilder().WithNotificationsToSend(_notificationProtocol1Id1);
            var push = builder.Build();

            push.Send();
            builder.AssertAddsToRepo(_notificationProtocol1Id1.ShipmentKey);
        }
        public void WithNewNotificationsToSend_Send_SendsTheNotification()
        {
            var builder =
                new PushNotificationCoordinatorBuilder().WithNotificationsToSend(_notificationProtocol1Id1);
            var push = builder.Build();

            push.Send();
            builder.AssetSendsNotifications(1);
        }
        public void WitTwoNotificationsOfDifferentTypesToDSameUser_Send_GroupsTheNotifications()
        {
            var builder =
                new PushNotificationCoordinatorBuilder()
                .WithNotificationsToSend(_notificationProtocol1Id1)
                .WithNotificationsToSend(_notificationExpiringProtocol1Id1);
            var push = builder.Build();

            push.Send();
            builder.AssetSendsNotifications(1);
        }
        public void WithTwoNotificationsToTheSameUserOneAlreadySent_Send_SendsOne()
        {
            var builder =
                new PushNotificationCoordinatorBuilder()
                .WithNotificationsToSend(_notificationProtocol1Id1)
                .WithNotificationsToSend(_notificationProtocol1Id2)
                .WithNotificationsAlreadySent(_notificationProtocol1Id1);
            var push = builder.Build();

            push.Send();
            builder.AssetSendsNotifications(1);
        }
        public void WithOneNotificationTo2DifferentUsers_Send_SendsBoth()
        {
            var builder =
                new PushNotificationCoordinatorBuilder().WithNotificationsToSend(_notificationProtocol1Id1)
                .WithUserSubscribedToProtocol(_notificationProtocol1Id1.ProtocolId, new List <string> {
                "user1", "user2"
            });
            var push = builder.Build();

            push.Send();
            builder.AssetSendsNotificationsToUsers(1, new List <string> {
                "user1", "user2"
            });
        }
        public void With100UsersAnd3Notifications_Send_SendsTo100Users()
        {
            var builder =
                new PushNotificationCoordinatorBuilder()
                .WithNotificationsToSend(_notificationProtocol1Id1)
                .WithNotificationsToSend(_notificationProtocol1Id2)
                .WithNotificationsToSend(_notificationExpiringProtocol1Id1)
                .WithUserSubscribedToProtocol(_notificationProtocol1Id1.ProtocolId, Enumerable.Range(0, 100).Select(u => $"User {u}").ToList());

            var push = builder.Build();

            push.Send();
            builder.AssetSendsNotifications(1, 100);
        }
        public void WithTwoDifferentNotificationsSubscribedBy2DifferentUsers_Send_DoesNotCombineTheNotifications()
        {
            // The push notification also contains the IDs so we can't group different IDs
            var builder =
                new PushNotificationCoordinatorBuilder()
                .WithNotificationsToSend(_notificationProtocol1Id1)
                .WithNotificationsToSend(_notificationProtocol1Id2)
                .WithNotificationsToSend(_notificationProtocol2Id1)
                .WithNotificationsToSend(_notificationProtocol2Id2)
                .WithUserSubscribedToProtocol(_notificationProtocol1Id1.ProtocolId, new List <string> {
                "user1"
            })
                .WithUserSubscribedToProtocol(_notificationProtocol2Id1.ProtocolId, new List <string> {
                "user2"
            });
            var push = builder.Build();

            push.Send();
            builder.AssetSendsNotifications(2, 1);
        }