コード例 #1
0
        private async Task <IReceivedNotification[]> ReceiveNotificationsAsync()
        {
            var notifications = EmptyArray.Get <IReceivedNotification>();

            if (RequestNotificationsRequired())
            {
                notifications = await m_channel.ReceiveNotificationsAsync();

                s_logger.Debug(
                    "Receive {NotificationCount} notifications {NotificationIds}.",
                    notifications.Length,
                    notifications.Select(n => n.Notification.NotificationId));
            }

            return(notifications);
        }
コード例 #2
0
        public async Task ChannelReceivesAllSendedNotifications()
        {
            var notifications = m_fixture.CreateMany <EventStreamUpdated>().ToList();

            foreach (var notification in notifications)
            {
                await m_channel.SendAsync(notification);
            }

            var receivedNotification = new List <INotification>();

            foreach (var _ in Enumerable.Range(0, notifications.Count()))
            {
                foreach (var notification in await m_channel.ReceiveNotificationsAsync())
                {
                    receivedNotification.Add(notification.Notification);
                    await notification.CompleteAsync();
                }
            }

            Assert.Equal(notifications.Count(), receivedNotification.Count);
        }