public void SendTo_WhenMessagHasBeenAddressedToTheSameConsumer_ReturnsItself(
            INotificationListener listener,
            EventStreamUpdated notification,
            EventStreamReaderId consumerId)
        {
            var addressedNotification = notification.SendTo(listener);

            Assert.Same(addressedNotification, addressedNotification.SendTo(listener));
        }
        public void SendTo_ChangesNotificationId(
            INotificationListener listener,
            EventStreamUpdated notification,
            EventStreamReaderId consumerId)
        {
            var addressedNotification = notification.SendTo(listener);

            Assert.NotEqual(notification.NotificationId, addressedNotification.NotificationId);
        }
 public void IsAddressedTo_WhenRecipientSpecifiedDirectly_ReturnsTrue(
     INotificationListener listener,
     EventStreamUpdated notification,
     EventStreamReaderId consumerId)
 {
     Assert.True(notification
                 .SendTo(listener)
                 .IsAddressedTo(listener));
 }
        public void SendTo_WhenMessagHasBeenAddressedToTheSameConsumer_SavesId(
            INotificationListener listener,
            EventStreamUpdated notification,
            EventStreamReaderId consumerId)
        {
            var addressedNotification = notification.SendTo(listener);

            Assert.Equal(
                addressedNotification.NotificationId,
                addressedNotification.SendTo(listener).NotificationId);
        }
 public void AddressedNotification_WhenRecipientIsDifferent_ReturnsFalse(
     ListenerType1 listener1,
     ListenerType2 listener2,
     EventStreamUpdated notification,
     EventStreamReaderId originalConsumer,
     EventStreamReaderId sendedConsumer)
 {
     Assert.False(notification
                  .SendTo(listener1)
                  .IsAddressedTo(listener2));
 }
        public void SendTo_PreservesNotificationPropertiesValues(
            INotificationListener listener,
            EventStreamUpdated notification,
            EventStreamReaderId consumerId)
        {
            var addressedNotification = (EventStreamUpdated)notification.SendTo(listener);

            Assert.Equal(notification.StreamName, addressedNotification.StreamName);
            Assert.Equal(notification.FromVersion, addressedNotification.FromVersion);
            Assert.Equal(notification.ToVersion, addressedNotification.ToVersion);
            Assert.Equal(notification.NotificationType, addressedNotification.NotificationType);
            Assert.Equal(notification.DeliveryCount, addressedNotification.DeliveryCount);
        }
        public async Task HandleNotificationAsync_WhenNotificationNotAddressedToConsumer_PropagatesNotificationToTheListener(
            [Frozen] Mock <INotificationListener> listenerMock,
            IEventStoreConnection connection,
            NotificationListenerSubscription subscription,
            EventStreamUpdated notification,
            EventStreamReaderId consumerId)
        {
            subscription.Start(connection);

            await subscription.HandleNotificationAsync(notification.SendTo(listenerMock.Object));

            listenerMock.Verify(
                self => self.On(notification),
                Times.Never());
        }