public void SetUp()
 {
     _topicEventReceiverOptionsValidator = new AzureTopicEventReceiverOptionsValidator();
     _topicEventReceiverOptions          = new AzureTopicEventReceiverOptions
     {
         ManagementConnectionString           = Constants.ValidConnectionString,
         ReceiveConnectionString              = Constants.ValidConnectionString,
         SubscriptionsAutoDeleteOnIdleTimeout = TimeSpan.MaxValue,
         TopicPath = "TopicPath"
     };
 }
        public void SetUp()
        {
            _options = new AzureTopicEventReceiverOptions
            {
                ReceiveConnectionString              = ReceiveConnectionString,
                ManagementConnectionString           = ManagementConnectionString,
                SubscriptionsAutoDeleteOnIdleTimeout = TimeSpan.FromDays(1),
                TopicPath = TopicPath,
                SubscriptionNameProvider = () => SubscriptionName,
                MaxConcurrentMessages    = 10
            };
            _loggerMock                     = new Mock <ILogger <AzureTopicEventReceiver> >(MockBehavior.Strict);
            _publishingServiceMock          = new Mock <IPublishingService>(MockBehavior.Strict);
            _eventsSerializationServiceMock = new Mock <IEventsSerializationService>(MockBehavior.Strict);
            _topicSubscriptionsServiceMock  = new Mock <ITopicSubscriptionsService>(MockBehavior.Strict);
            _subscriptionClientFactoryMock  = new Mock <ISubscriptionClientFactory>(MockBehavior.Strict);
            _subscriptionClientMock         = new Mock <ISubscriptionClient>(MockBehavior.Strict);

            _azureTopicEventReceiver = new AzureTopicEventReceiver(
                _loggerMock.Object,
                Options.Create(_options),
                _publishingServiceMock.Object,
                _eventsSerializationServiceMock.Object,
                _topicSubscriptionsServiceMock.Object,
                _subscriptionClientFactoryMock.Object
                );


            _subscriptionClientFactoryMock
            .Setup(x => x.GetNew(_options.ReceiveConnectionString, SubscriptionName))
            .Returns(_subscriptionClientMock.Object)
            .Verifiable();

            _messageHandler        = null;
            _messageHandlerOptions = null;

            _subscriptionClientMock
            .Setup(x => x.RegisterMessageHandler(
                       It.IsAny <Func <Message, CancellationToken, Task> >(),
                       It.Is <MessageHandlerOptions>(y => y.MaxConcurrentCalls == _options.MaxConcurrentMessages)
                       ))
            .Callback <Func <Message, CancellationToken, Task>, MessageHandlerOptions>((x, y) =>
            {
                _messageHandler        = x;
                _messageHandlerOptions = y;
            })
            .Verifiable();
        }