예제 #1
0
        public AzureStorageQueueClient(IOptions <NotifyConfiguration> notifyConfigOptions, IOptions <ConnectionStrings> connectionStringsOptions)
        {
            this.notifyConfig      = notifyConfigOptions.Value;
            this.connectionStrings = connectionStringsOptions.Value;

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(this.connectionStrings.StorageAccount);

            this.queueClient = storageAccount.CreateCloudQueueClient();
        }
        public SmsMessageQueueTests()
        {
            _testStorage          = new TestStorage();
            _mockSmsQueueProvider = new Mock <ISmsQueueProvider>();
            _mockNotifyOptions    = new Mock <IOptions <Core.Configuration.Notify> >();

            _testOutgoingQueueName = Guid.NewGuid().ToString();
            var testNotify = new Core.Configuration.Notify {
                OutgoingMessageQueueName = _testOutgoingQueueName
            };

            _mockNotifyOptions.Setup(m => m.Value).Returns(testNotify);

            _mockNext          = new Mock <NextDelegate>();
            _conversationState = new ConversationState(_testStorage);
            _userState         = new UserState(_testStorage);
            _mockUserState     = new Mock <UserState>();

            _mockConversationDialogState = new Mock <IStatePropertyAccessor <Microsoft.Bot.Builder.Dialogs.DialogState> >();
            _feedbackBotStateRepository  = new FeedbackBotStateRepository(_conversationState, _userState);
            _feedbackBotStateRepository.ConversationDialogState = _mockConversationDialogState.Object;

            _mockTurnContext = new Mock <ITurnContext>();
            _mockTurnContext
            .Setup(m => m.TurnState)
            .Returns(new TurnContextStateCollection());

            _testActivityList = new List <Activity>();

            // set up the test activity with some random text and known ChannelId and ConversationId
            _testActivity = new Activity
            {
                Id           = Guid.NewGuid().ToString(),
                Type         = ActivityTypes.Message,
                Text         = Guid.NewGuid().ToString(),
                ChannelId    = "Test",
                Conversation = new ConversationAccount()
                {
                    Id = "TestConversation"
                },
                From = new ChannelAccount {
                    Id = "TestFromAccount"
                },
                Recipient = new ChannelAccount {
                    Id = "TestRecipientAccount"
                },
                ChannelData = new object()
            };

            _mockTurnContext
            .Setup(m => m.Activity)
            .Returns(_testActivity);

            _mockTurnContext
            .Setup(m => m.OnSendActivities(It.IsAny <SendActivitiesHandler>()))
            .Callback <SendActivitiesHandler>(async(handler) =>
            {
                await handler.Invoke(_mockTurnContext.Object, _testActivityList, () => Task.FromResult(new List <ResourceResponse>().ToArray()));
            });

            _sut = new SmsMessageQueue(_mockSmsQueueProvider.Object, _mockNotifyOptions.Object, _feedbackBotStateRepository);
        }