Beispiel #1
0
        public void ExpectedRepliesInitsWithNoArgs()
        {
            var expectedReplies = new ExpectedReplies();

            Assert.NotNull(expectedReplies);
            Assert.IsType <ExpectedReplies>(expectedReplies);
        }
        private static Mock <BotFrameworkClient> CreateMockSkillClient(Action <string, string, Uri, Uri, string, Activity, CancellationToken> captureAction, int returnStatus = 200)
        {
            var mockSkillClient = new Mock <BotFrameworkClient>();
            var activityList    = new ExpectedReplies(new List <Activity> {
                MessageFactory.Text("dummy activity")
            });

            if (captureAction != null)
            {
                mockSkillClient
                .Setup(x => x.PostActivityAsync <ExpectedReplies>(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Uri>(), It.IsAny <Uri>(), It.IsAny <string>(), It.IsAny <Activity>(), It.IsAny <CancellationToken>()))
                .Returns(Task.FromResult(new InvokeResponse <ExpectedReplies>
                {
                    Status = returnStatus,
                    Body   = activityList
                }))
                .Callback(captureAction);
            }
            else
            {
                mockSkillClient
                .Setup(x => x.PostActivityAsync <ExpectedReplies>(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Uri>(), It.IsAny <Uri>(), It.IsAny <string>(), It.IsAny <Activity>(), It.IsAny <CancellationToken>()))
                .Returns(Task.FromResult(new InvokeResponse <ExpectedReplies>
                {
                    Status = returnStatus,
                    Body   = activityList
                }));
            }

            return(mockSkillClient);
        }
        public async Task ShouldNotInterceptOAuthCardsForTokenException()
        {
            var connectionName = "connectionName";
            var firstResponse  = new ExpectedReplies(new List <Activity> {
                CreateOAuthCardAttachmentActivity("https://test")
            });
            var mockSkillClient = new Mock <BotFrameworkClient>();

            mockSkillClient
            .Setup(x => x.PostActivityAsync <ExpectedReplies>(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <Uri>(), It.IsAny <Uri>(), It.IsAny <string>(), It.IsAny <Activity>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(new InvokeResponse <ExpectedReplies>
            {
                Status = 200,
                Body   = firstResponse
            }));

            var conversationState = new ConversationState(new MemoryStorage());
            var dialogOptions     = CreateSkillDialogOptions(conversationState, mockSkillClient, connectionName);

            var sut            = new SkillDialog(dialogOptions);
            var activityToSend = CreateSendActivity();
            var testAdapter    = new TestAdapter(Channels.Test)
                                 .Use(new AutoSaveStateMiddleware(conversationState));
            var initialDialogOptions = new BeginSkillDialogOptions {
                Activity = activityToSend
            };
            var client = new DialogTestClient(testAdapter, sut, initialDialogOptions, conversationState: conversationState);

            testAdapter.ThrowOnExchangeRequest(connectionName, Channels.Test, "user1", "https://test");
            var finalActivity = await client.SendActivityAsync <IMessageActivity>("irrelevant");

            Assert.IsNotNull(finalActivity);
            Assert.IsTrue(finalActivity.Attachments.Count == 1);
        }
Beispiel #4
0
        public void ExpectedRepliesInits()
        {
            var activities = new List <Activity>()
            {
                new Activity()
            };

            var expectedReplies = new ExpectedReplies(activities);

            Assert.NotNull(expectedReplies);
            Assert.IsType <ExpectedReplies>(expectedReplies);
            Assert.Equal(activities, expectedReplies.Activities);
        }